[llvm-commits] [llvm] r127964 - /llvm/trunk/lib/CodeGen/InlineSpiller.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Sat Mar 19 22:44:55 PDT 2011


Author: stoklund
Date: Sun Mar 20 00:44:55 2011
New Revision: 127964

URL: http://llvm.org/viewvc/llvm-project?rev=127964&view=rev
Log:
Change an argument to a LiveInterval instead of a register number to save some redundant lookups.

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

Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=127964&r1=127963&r2=127964&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
+++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Sun Mar 20 00:44:55 2011
@@ -124,7 +124,7 @@
   void analyzeSiblingValues();
 
   bool hoistSpill(LiveInterval &SpillLI, MachineInstr *CopyMI);
-  void eliminateRedundantSpills(unsigned Reg, VNInfo *VNI);
+  void eliminateRedundantSpills(LiveInterval &LI, VNInfo *VNI);
 
   bool reMaterializeFor(MachineBasicBlock::iterator MI);
   void reMaterializeAll();
@@ -444,7 +444,7 @@
 
   // We are going to spill SVI.SpillVNI immediately after its def, so clear out
   // any later spills of the same value.
-  eliminateRedundantSpills(SVI.SpillReg, SVI.SpillVNI);
+  eliminateRedundantSpills(LIS.getInterval(SVI.SpillReg), SVI.SpillVNI);
 
   MachineBasicBlock *MBB = LIS.getMBBFromIndex(SVI.SpillVNI->def);
   MachineBasicBlock::iterator MII;
@@ -463,15 +463,17 @@
   return true;
 }
 
-/// eliminateRedundantSpills - Reg:VNI is known to be on the stack. Remove any
-/// redundant spills of this value in Reg and sibling copies.
-void InlineSpiller::eliminateRedundantSpills(unsigned Reg, VNInfo *VNI) {
-  SmallVector<std::pair<unsigned, VNInfo*>, 8> WorkList;
-  WorkList.push_back(std::make_pair(Reg, VNI));
+/// eliminateRedundantSpills - SLI:VNI is known to be on the stack. Remove any
+/// redundant spills of this value in SLI.reg and sibling copies.
+void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) {
+  SmallVector<std::pair<LiveInterval*, VNInfo*>, 8> WorkList;
+  WorkList.push_back(std::make_pair(&SLI, VNI));
   LiveInterval &StackInt = LSS.getInterval(StackSlot);
 
   do {
-    tie(Reg, VNI) = WorkList.pop_back_val();
+    LiveInterval *LI;
+    tie(LI, VNI) = WorkList.pop_back_val();
+    unsigned Reg = LI->reg;
     DEBUG(dbgs() << "Checking redundant spills for " << PrintReg(Reg) << ':'
                  << VNI->id << '@' << VNI->def << '\n');
 
@@ -480,8 +482,7 @@
       continue;
 
     // Add all of VNI's live range to StackInt.
-    LiveInterval &LI = LIS.getInterval(Reg);
-    StackInt.MergeValueInAsValue(LI, VNI, StackInt.getValNumInfo(0));
+    StackInt.MergeValueInAsValue(*LI, VNI, StackInt.getValNumInfo(0));
     DEBUG(dbgs() << "Merged to stack int: " << StackInt << '\n');
 
     // Find all spills and copies of VNI.
@@ -490,7 +491,7 @@
       if (!MI->isCopy() && !MI->getDesc().mayStore())
         continue;
       SlotIndex Idx = LIS.getInstructionIndex(MI);
-      if (LI.getVNInfoAt(Idx) != VNI)
+      if (LI->getVNInfoAt(Idx) != VNI)
         continue;
 
       // Follow sibling copies down the dominator tree.
@@ -500,7 +501,7 @@
            VNInfo *DstVNI = DstLI.getVNInfoAt(Idx.getDefIndex());
            assert(DstVNI && "Missing defined value");
            assert(DstVNI->def == Idx.getDefIndex() && "Wrong copy def slot");
-           WorkList.push_back(std::make_pair(DstReg, DstVNI));
+           WorkList.push_back(std::make_pair(&DstLI, DstVNI));
         }
         continue;
       }
@@ -841,7 +842,6 @@
   Edit = &edit;
   assert(!TargetRegisterInfo::isStackSlot(edit.getReg())
          && "Trying to spill a stack slot.");
-
   // Share a stack slot among all descendants of Original.
   Original = VRM.getOriginal(edit.getReg());
   StackSlot = VRM.getStackSlot(Original);





More information about the llvm-commits mailing list