[llvm-commits] [llvm] r63339 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp

Owen Anderson resistor at mac.com
Thu Jan 29 14:13:07 PST 2009


Author: resistor
Date: Thu Jan 29 16:13:06 2009
New Revision: 63339

URL: http://llvm.org/viewvc/llvm-project?rev=63339&view=rev
Log:
Correct the algorithms for choosing spill and restore points so that we don't try to insert loads/stores between call frame setup and the actual call.

This fixes the last known failure for the pre-alloc-splitter.

Modified:
    llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp

Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=63339&r1=63338&r2=63339&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original)
+++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Thu Jan 29 16:13:06 2009
@@ -50,6 +50,7 @@
     MachineFunction       *CurrMF;
     const TargetMachine   *TM;
     const TargetInstrInfo *TII;
+    const TargetRegisterInfo* TRI;
     MachineFrameInfo      *MFI;
     MachineRegisterInfo   *MRI;
     LiveIntervals         *LIs;
@@ -223,12 +224,21 @@
         Pt = MII;
         SpillIndex = Gap;
         break;
-      }
+      
+      // We can't insert the spill between the barrier (a call), and its
+      // corresponding call frame setup.
+      } else if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode() &&
+                 MII == MachineBasicBlock::iterator(MI))
+        break;
     } while (MII != EndPt);
   } else {
     MachineBasicBlock::iterator MII = MI;
     MachineBasicBlock::iterator EndPt = DefMI
       ? MachineBasicBlock::iterator(DefMI) : MBB->begin();
+    
+    // We can't insert the spill between the barrier (a call), and its
+    // corresponding call frame setup.
+    if (prior(MII)->getOpcode() == TRI->getCallFrameSetupOpcode()) --MII;
     while (MII != EndPt && !RefsInMBB.count(MII)) {
       unsigned Index = LIs->getInstructionIndex(MII);
       if (LIs->hasGapBeforeInstr(Index)) {
@@ -269,12 +279,22 @@
         Pt = MII;
         RestoreIndex = Gap;
         break;
-      }
+      
+      // We can't insert a restore between the barrier (a call) and its 
+      // corresponding call frame teardown.
+      } else if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode() &&
+                 prior(MII) == MachineBasicBlock::iterator(MI))
+        break;
       --MII;
     } while (MII != EndPt);
   } else {
     MachineBasicBlock::iterator MII = MI;
     MII = ++MII;
+    // We can't insert a restore between the barrier (a call) and its 
+    // corresponding call frame teardown.
+    if (MII->getOpcode() == TRI->getCallFrameDestroyOpcode())
+      ++MII;
+    
     // FIXME: Limit the number of instructions to examine to reduce
     // compile time?
     while (MII != MBB->getFirstTerminator()) {
@@ -1291,6 +1311,7 @@
 bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
   CurrMF = &MF;
   TM     = &MF.getTarget();
+  TRI    = TM->getRegisterInfo();
   TII    = TM->getInstrInfo();
   MFI    = MF.getFrameInfo();
   MRI    = &MF.getRegInfo();





More information about the llvm-commits mailing list