Author: evancheng
Date: Mon Dec  3 18:32:23 2007
New Revision: 44565

URL: http://llvm.org/viewvc/llvm-project?rev=44565&view=rev
Log:
Discard split intervals made empty due to folding.

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=44565&r1=44564&r2=44565&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Dec  3 18:32:23 2007
@@ -1234,6 +1234,7 @@
       for (unsigned i = 0, e = spills.size(); i != e; ++i) {
         int index = spills[i].index;
         unsigned VReg = spills[i].vreg;
+        LiveInterval &nI = getOrCreateInterval(VReg);
         bool isReMat = vrm.isReMaterialized(VReg);
         MachineInstr *MI = getInstructionFromIndex(index);
         bool CanFold = false;
@@ -1269,6 +1270,7 @@
             if (FoundUse > 0)
               // Also folded uses, do not issue a load.
               eraseRestoreInfo(Id, index, VReg, RestoreMBBs, RestoreIdxes);
+            nI.removeRange(getDefIndex(index), getStoreIndex(index));
           }
         }
 
@@ -1288,6 +1290,7 @@
       if (index == -1)
         continue;
       unsigned VReg = restores[i].vreg;
+      LiveInterval &nI = getOrCreateInterval(VReg);
       MachineInstr *MI = getInstructionFromIndex(index);
       bool CanFold = false;
       Ops.clear();
@@ -1326,15 +1329,23 @@
       }
       // If folding is not possible / failed, then tell the spiller to issue a
       // load / rematerialization for us.
-      if (!Folded)
+      if (Folded)
+        nI.removeRange(getLoadIndex(index), getUseIndex(index)+1);
+      else
         vrm.addRestorePoint(VReg, MI);
     }
     Id = RestoreMBBs.find_next(Id);
   }
 
-  // Finalize spill weights.
-  for (unsigned i = 0, e = NewLIs.size(); i != e; ++i)
-    NewLIs[i]->weight /= NewLIs[i]->getSize();
+  // Finalize spill weights and filter out dead intervals.
+  std::vector<LiveInterval*> RetNewLIs;
+  for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) {
+    LiveInterval *LI = NewLIs[i];
+    if (!LI->empty()) {
+      LI->weight /= LI->getSize();
+      RetNewLIs.push_back(LI);
+    }
+  }
 
-  return NewLIs;
+  return RetNewLIs;
 }


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to