diff options
| author | Eric Christopher <echristo@apple.com> | 2011-01-11 00:16:04 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@apple.com> | 2011-01-11 00:16:04 +0000 |
| commit | 3904343c68926f1ed8250e4a9b0863868f1ffb74 (patch) | |
| tree | 28410e2017bbd22e8783d802c65349c55a42de20 /llvm/lib/Target/ARM/Thumb1FrameLowering.cpp | |
| parent | bd4520b53523634d20bb56bb40a40d56125260fe (diff) | |
| download | bcm5719-llvm-3904343c68926f1ed8250e4a9b0863868f1ffb74.tar.gz bcm5719-llvm-3904343c68926f1ed8250e4a9b0863868f1ffb74.zip | |
Even if we don't have 7 bytes of stack space we may need to save and
restore the stack pointer from the frame pointer on thumbv6.
Fixes rdar://8819685
llvm-svn: 123196
Diffstat (limited to 'llvm/lib/Target/ARM/Thumb1FrameLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/Thumb1FrameLowering.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp index e3f2d2d5981..8a6dda82148 100644 --- a/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp +++ b/llvm/lib/Target/ARM/Thumb1FrameLowering.cpp @@ -156,6 +156,12 @@ void Thumb1FrameLowering::emitPrologue(MachineFunction &MF) const { // to reference locals. if (RegInfo->hasBasePointer(MF)) BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), BasePtr).addReg(ARM::SP); + + // If the frame has variable sized objects then the epilogue must restore + // the sp from fp. We can assume there's an FP here since hasFP already + // checks for hasVarSizedObjects. + if (MFI->hasVarSizedObjects()) + AFI->setShouldRestoreSPFromFP(true); } static bool isCalleeSavedRegister(unsigned Reg, const unsigned *CSRegs) { @@ -221,7 +227,8 @@ void Thumb1FrameLowering::emitEpilogue(MachineFunction &MF, if (AFI->shouldRestoreSPFromFP()) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. + // frame pointer stack slot, the target is ELF and the function has FP, or + // the target uses var sized objects. if (NumBytes) { assert(MF.getRegInfo().isPhysRegUsed(ARM::R4) && "No scratch register to restore SP from FP!"); |

