[llvm-commits] [llvm] r54949 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Owen Anderson resistor at mac.com
Mon Aug 18 14:20:35 PDT 2008


Author: resistor
Date: Mon Aug 18 16:20:32 2008
New Revision: 54949

URL: http://llvm.org/viewvc/llvm-project?rev=54949&view=rev
Log:
Fix several bugs in the new fast-path:
  1) Remove an incorrect assertion.
  2) Set the stack slot weight properly.
  3) Resize the VirtRegMap when needed.

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

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=54949&r1=54948&r2=54949&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 18 16:20:32 2008
@@ -1608,11 +1608,7 @@
 addIntervalsForSpillsFast(const LiveInterval &li,
                           const MachineLoopInfo *loopInfo,
                           VirtRegMap &vrm, float& SSWeight) {
-  unsigned slot = vrm.assignVirt2StackSlot(li.reg);
-  
-  // since this is called after the analysis is done we don't know if
-  // LiveVariables is available
-  lv_ = getAnalysisToUpdate<LiveVariables>();
+  vrm.assignVirt2StackSlot(li.reg);
 
   std::vector<LiveInterval*> added;
 
@@ -1628,14 +1624,17 @@
   DenseMap<MachineInstr*, unsigned> VRegMap;
   DenseMap<MachineInstr*, VNInfo*> VNMap;
 
+  SSWeight = 0.0f;
+
   for (MachineRegisterInfo::reg_iterator RI = mri_->reg_begin(li.reg),
        RE = mri_->reg_end(); RI != RE; ) {
     // Create a new virtual register for the spill interval.
     MachineOperand& MO = RI.getOperand();
     unsigned NewVReg = 0;
-    if (!VRegMap.count(MO.getParent()))
+    if (!VRegMap.count(MO.getParent())) {
       VRegMap[MO.getParent()] = NewVReg = mri_->createVirtualRegister(rc);
-    else
+      vrm.grow();
+    } else
       NewVReg = VRegMap[MO.getParent()];
     
     // Increment iterator to avoid invalidation.
@@ -1644,10 +1643,7 @@
     MO.setReg(NewVReg);
 
     // create a new register for this spill
-    vrm.grow();
-    vrm.assignVirt2StackSlot(NewVReg, slot);
     LiveInterval &nI = getOrCreateInterval(NewVReg);
-    assert(nI.empty());
 
     // the spill weight is now infinity as it
     // cannot be spilled again
@@ -1672,17 +1668,21 @@
     }
         
     added.push_back(&nI);
-
-    // update live variables if it is available
-    if (lv_)
-      lv_->addVirtualRegisterKilled(NewVReg, MO.getParent());
         
     DOUT << "\t\t\t\tadded new interval: ";
     DEBUG(nI.dump());
     DOUT << '\n';
+    
+    unsigned loopDepth = loopInfo->getLoopDepth(MO.getParent()->getParent());
+    if (HasUse) {
+      if (HasDef)
+        SSWeight += getSpillWeight(true, true, loopDepth);
+      else
+        SSWeight += getSpillWeight(false, true, loopDepth);
+    } else
+      SSWeight += getSpillWeight(true, false, loopDepth);
+    
   }
-  
-  SSWeight = HUGE_VALF;
 
   std::sort(added.begin(), added.end(), LISorter());
 





More information about the llvm-commits mailing list