Heal EH handling stuff by emitting correct offsets to callee-saved registers.
authorAnton Korobeynikov <asl@math.spbu.ru>
Tue, 24 Jul 2007 21:07:39 +0000 (21:07 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Tue, 24 Jul 2007 21:07:39 +0000 (21:07 +0000)
Pretty hackish, but code itself is dirty mess, so we won't make anything worse. :)

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

lib/Target/X86/X86RegisterInfo.cpp

index f4fd4522aed8f23b1a22df06a225da74a840cce0..29bdf94a68d6a8f572b770641967b0c2599a6d62 100644 (file)
@@ -1297,9 +1297,21 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
             
     // Add callee saved registers to move list.
     const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
-    for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
+
+    // FIXME: This is dirty hack. The code itself is pretty mess right now.
+    // It should be rewritten from scratch and generalized sometimes.
+    
+    // Determine maximum offset (minumum due to stack growth)
+    int64_t MaxOffset = 0;
+    for (unsigned I = 0, E = CSI.size(); I!=E; ++I)
+      MaxOffset = std::min(MaxOffset,
+                           MFI->getObjectOffset(CSI[I].getFrameIdx()));
+
+    // Calculate offsets
+    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);
       MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
       MachineLocation CSSrc(Reg);
       Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc));