summaryrefslogtreecommitdiff
path: root/lib/Target/ARM/Thumb1FrameLowering.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-01-14 22:53:28 +0000
committerTim Northover <tnorthover@apple.com>2014-01-14 22:53:28 +0000
commit196c8e5fbb71098e2910e038b78f2938e3e832ff (patch)
treedc7512dd6c75bfe306286d65d69e7241db48777b /lib/Target/ARM/Thumb1FrameLowering.cpp
parent4e1247b836546287d2db40575a8daaca31351e86 (diff)
downloadllvm-196c8e5fbb71098e2910e038b78f2938e3e832ff.tar.gz
llvm-196c8e5fbb71098e2910e038b78f2938e3e832ff.tar.bz2
llvm-196c8e5fbb71098e2910e038b78f2938e3e832ff.tar.xz
ARM: correctly determine final tBX_LR in Thumb1 functions
The changes caused by folding an sp-adjustment into a "pop" previously disrupted the forward search for the final real instruction in a terminating block. This switches to a backward search (skipping debug instrs). This fixes PR18399. Patch by Zhaoshi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199266 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/Thumb1FrameLowering.cpp')
-rw-r--r--lib/Target/ARM/Thumb1FrameLowering.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Target/ARM/Thumb1FrameLowering.cpp b/lib/Target/ARM/Thumb1FrameLowering.cpp
index d8546dac31..2a587dd25b 100644
--- a/lib/Target/ARM/Thumb1FrameLowering.cpp
+++ b/lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -304,9 +304,9 @@ void Thumb1FrameLowering::emitEpilogue(MachineFunction &MF,
// we need to update the SP after popping the value. Therefore, we
// pop the old LR into R3 as a temporary.
- // Move back past the callee-saved register restoration
- while (MBBI != MBB.end() && isCSRestore(MBBI, CSRegs))
- ++MBBI;
+ // Get the last instruction, tBX_RET
+ MBBI = MBB.getLastNonDebugInstr();
+ assert (MBBI->getOpcode() == ARM::tBX_RET);
// Epilogue for vararg functions: pop LR to R3 and branch off it.
AddDefaultPred(BuildMI(MBB, MBBI, dl, TII.get(ARM::tPOP)))
.addReg(ARM::R3, RegState::Define);