Fix off-by-one stack offset computations (dwarf information) for callee-saved
authorAnton Korobeynikov <asl@math.spbu.ru>
Fri, 26 Oct 2007 09:13:24 +0000 (09:13 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Fri, 26 Oct 2007 09:13:24 +0000 (09:13 +0000)
registers in case, when FP pointer was eliminated. This should fixes misc. random
EH-related crahses, when stuff is compiled with -fomit-frame-pointer.
Thanks Duncan for nailing this bug!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43381 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86RegisterInfo.cpp

index 72e0fe44b306cb83fda8556e4938c2bd30c864df..a7b98b528ce47fbc9d6ee31a3c36fc44e961461e 100644 (file)
@@ -1816,10 +1816,11 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
                            MFI->getObjectOffset(CSI[I].getFrameIdx()));
 
     // Calculate offsets
+    int64_t saveAreaOffset = (hasFP(MF) ? 3 : 2)*stackGrowth;
     for (unsigned I = 0, E = CSI.size(); I!=E; ++I) {
       int64_t Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
       unsigned Reg = CSI[I].getReg();
-      Offset = (MaxOffset-Offset+3*stackGrowth);
+      Offset = (MaxOffset-Offset+saveAreaOffset);
       MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
       MachineLocation CSSrc(Reg);
       Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc));