Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 25718c2

Browse files
committed
Revert "Use R0/R1 instead of R4/R5 for ARM eh_return return values"
This reverts commit 43d482a. It doesn't work correctly. It probably makes more sense to switch to EABI unwinding than put too much more effort into debugging this. [email protected] BUG= https://code.google.com/p/nativeclient/issues/detail?id=4171 Review URL: https://codereview.chromium.org/1173643002.
1 parent d2a9f29 commit 25718c2

File tree

5 files changed

+16
-81
lines changed

5 files changed

+16
-81
lines changed

lib/Target/ARM/ARMBaseRegisterInfo.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "llvm/CodeGen/MachineFrameInfo.h"
2525
#include "llvm/CodeGen/MachineFunction.h"
2626
#include "llvm/CodeGen/MachineInstrBuilder.h"
27-
#include "llvm/CodeGen/MachineModuleInfo.h" // @LOCALMOD
2827
#include "llvm/CodeGen/MachineRegisterInfo.h"
2928
#include "llvm/CodeGen/RegisterScavenging.h"
3029
#include "llvm/CodeGen/VirtRegMap.h"
@@ -64,14 +63,7 @@ static unsigned getFramePointerReg(const ARMSubtarget &STI) {
6463
const MCPhysReg*
6564
ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
6665
const ARMSubtarget &STI = MF->getSubtarget<ARMSubtarget>();
67-
// @LOCALMOD-START
68-
// We don't support special calling conventions for NaCl here.
69-
if (STI.isTargetNaCl()) {
70-
if (MF->getMMI().callsEHReturn())
71-
return CSR_NaCl_EHRet_SaveList;
72-
return CSR_NaCl_SaveList;
73-
}
74-
// @LOCALMOD-END
66+
if (STI.isTargetNaCl()) return CSR_NaCl_SaveList; // @LOCALMOD
7567

7668
const MCPhysReg *RegList =
7769
STI.isTargetDarwin() ? CSR_iOS_SaveList : CSR_AAPCS_SaveList;

lib/Target/ARM/ARMCallingConv.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,4 @@ def CSR_FIQ : CalleeSavedRegs<(add LR, R11, (sequence "R%u", 7, 0))>;
242242
// NaCl does not save R9, but otherwise uses the same order as AAPCS
243243
def CSR_NaCl : CalleeSavedRegs<(add LR, R11, R10, R8, R7, R6, R5, R4,
244244
(sequence "D%u", 15, 8))>;
245-
def CSR_NaCl_EHRet : CalleeSavedRegs<(add CSR_NaCl, R1, R0)>;
246245
// @LOCALMOD-END

lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,6 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
966966
isKill = false;
967967
}
968968

969-
// @LOCALMOD-START
970-
// Functions which call EHReturn spill all CSRs plus R0/R1
971-
if ((Reg == ARM::R0 || Reg == ARM::R1) &&
972-
MF.getRegInfo().isLiveIn(Reg)) {
973-
assert(MF.getMMI().callsEHReturn());
974-
isKill = false;
975-
}
976-
// @LOCALMOD-END
977-
978969
if (isKill)
979970
MBB.addLiveIn(Reg);
980971

@@ -1034,7 +1025,6 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
10341025
while (i != 0) {
10351026
unsigned LastReg = 0;
10361027
bool DeleteRet = false;
1037-
unsigned SkippedPop = 0; // @LOCALMOD
10381028
for (; i != 0; --i) {
10391029
unsigned Reg = CSI[i-1].getReg();
10401030
if (!(Func)(Reg, STI.isTargetDarwin())) continue;
@@ -1043,19 +1033,6 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
10431033
if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
10441034
continue;
10451035

1046-
// @LOCALMOD-START
1047-
// Functions which call EHReturn spill all of their CSRs plus R0 and R1,
1048-
// (the EHReturn return value registers). Epilogs which return via
1049-
// EHreturn pop all of them, but epilogs which return via normal return
1050-
// must not restore R0 and R1, as that would clobber the return value.
1051-
if (MF.getMMI().callsEHReturn() &&
1052-
RetOpcode != ARM::ARMeh_return &&
1053-
(Reg == ARM::R0 || Reg == ARM::R1)) {
1054-
SkippedPop++;
1055-
continue;
1056-
}
1057-
// @LOCALMOD-END
1058-
10591036
if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
10601037
STI.hasV5TOps() &&
10611038
!STI.isTargetNaCl() /* @LOCALMOD */) {
@@ -1075,21 +1052,6 @@ void ARMFrameLowering::emitPopInst(MachineBasicBlock &MBB,
10751052
Regs.push_back(Reg);
10761053
}
10771054

1078-
// @LOCALMOD-START
1079-
if (SkippedPop) {
1080-
// We need to increment the stack pointer to compensate for the skipped
1081-
// pops. However we cannot directly increment it because the epilog
1082-
// insertion code places the stack pointer restore before the CSR
1083-
// restores; it does this by finding the first instruction that's not a
1084-
// pop. If we put an add here, the restore would go in between the
1085-
// restore of the FP registers and the GPRs, instead of before the FP
1086-
// restore. So use a pop into R12 to adjust SP.
1087-
while(SkippedPop--)
1088-
AddDefaultPred(BuildMI(MBB, MI, DL, TII.get(LdmOpc), ARM::SP)
1089-
.addReg(ARM::SP)).addReg(ARM::R12);
1090-
}
1091-
// @LOCALMOD-END
1092-
10931055
if (Regs.empty())
10941056
continue;
10951057
if (Regs.size() > 1 || LdrOpc == 0) {

lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,16 +765,23 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
765765
if (!Subtarget->isTargetMachO()) {
766766
// Non-MachO platforms may return values in these registers via the
767767
// personality function.
768-
setExceptionPointerRegister(ARM::R0);
769-
setExceptionSelectorRegister(ARM::R1);
770-
}
768+
// @LOCALMOD-START
769+
if (Subtarget->isTargetNaCl()) {
770+
// we use the first caller saved regs here
771+
// c.f.: llvm-gcc/llvm-gcc-4.2/gcc/unwind-dw2.c::uw_install_context
772+
// NOTE: these are related to the _Unwind_PNaClSetResult{0,1} functions
773+
setExceptionPointerRegister(ARM::R4);
774+
setExceptionSelectorRegister(ARM::R5);
775+
776+
setOperationAction(ISD::FRAME_TO_ARGS_OFFSET, MVT::i32, Custom);
771777

772-
// @LOCALMOD-START
773-
if (Subtarget->isTargetNaCl()) {
774-
setOperationAction(ISD::FRAME_TO_ARGS_OFFSET, MVT::i32, Custom);
775-
setOperationAction(ISD::EH_RETURN, MVT::Other, Custom);
778+
setOperationAction(ISD::EH_RETURN, MVT::Other, Custom);
779+
} else {
780+
setExceptionPointerRegister(ARM::R0);
781+
setExceptionSelectorRegister(ARM::R1);
782+
}
783+
// @LOCALMOD-END
776784
}
777-
// @LOCALMOD-END
778785

779786
if (Subtarget->getTargetTriple().isWindowsItaniumEnvironment())
780787
setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom);

test/CodeGen/ARM/ehreturn.ll

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)