fix the loading of the link register in emitepilogue
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Aug 2006 13:15:47 +0000 (13:15 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 9 Aug 2006 13:15:47 +0000 (13:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29580 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMRegisterInfo.cpp

index 67d0b7c801aa22bbe1afc2c93ce6b63d7d687769..9c607691eaa1f9d11bb89311ae4f744acb5b5c2a 100644 (file)
@@ -129,6 +129,8 @@ void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
     // entry to the current function.  This eliminates the need for add/sub
     // brackets around call sites.
     NumBytes += MFI->getMaxCallFrameSize();
+  } else {
+    NumBytes += 4;
   }
 
   MFI->setStackSize(NumBytes);
@@ -149,7 +151,7 @@ void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
   int          NumBytes = (int) MFI->getStackSize();
 
   //ldr lr, [sp]
-  BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R14).addImm(0).addReg(ARM::R13);
+  BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R14).addImm(NumBytes - 4).addReg(ARM::R13);
   //add sp, sp, #NumBytes
   BuildMI(MBB, MBBI, ARM::addri, 2, ARM::R13).addReg(ARM::R13).addImm(NumBytes);
 }