Add LiveInterval::RenumberValues - Garbage collection for VNInfos.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 6 Aug 2010 18:46:59 +0000 (18:46 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 6 Aug 2010 18:46:59 +0000 (18:46 +0000)
After heavy editing of a live interval, it is much easier to simply renumber the
live values instead of trying to keep track of the unused ones.

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

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveInterval.cpp
lib/CodeGen/SplitKit.cpp

index 2e0651dcc16d7f09f5abf3344e0926bf7f858288..0c92b853402525fd00d9c4e59bec9a45f85d5c4a 100644 (file)
@@ -336,6 +336,10 @@ namespace llvm {
       return VNI;
     }
 
+    /// RenumberValues - Renumber all values in order of appearance and remove
+    /// unused values.
+    void RenumberValues();
+
     /// isOnlyLROfValNo - Return true if the specified live range is the only
     /// one defined by the its val#.
     bool isOnlyLROfValNo(const LiveRange *LR) {
index 14b10d18256054fcc3169298f4a58129b2fd895f..f4c06b203cbcba3bce67ff1d446afd0f740ab220 100644 (file)
@@ -180,6 +180,21 @@ void LiveInterval::markValNoForDeletion(VNInfo *ValNo) {
   }
 }
 
+/// RenumberValues - Renumber all values in order of appearance and delete the
+/// remaining unused values.
+void LiveInterval::RenumberValues() {
+  SmallPtrSet<VNInfo*, 8> Seen;
+  valnos.clear();
+  for (const_iterator I = begin(), E = end(); I != E; ++I) {
+    VNInfo *VNI = I->valno;
+    if (!Seen.insert(VNI))
+      continue;
+    assert(!VNI->isUnused() && "Unused valno used by live range");
+    VNI->id = (unsigned)valnos.size();
+    valnos.push_back(VNI);
+  }
+}
+
 /// extendIntervalEndTo - This method is used when we want to extend the range
 /// specified by I to end at the specified endpoint.  To do this, we should
 /// merge and eliminate all ranges that this will overlap with.  The iterator is
index fdc448d1e8b48dad0990c7b8ebfc90026f851f55..9b0d73a4f2399ff278dcfa2f188f572e3e23b67b 100644 (file)
@@ -553,8 +553,10 @@ void SplitEditor::rewrite() {
   }
 
   // dupli_ goes in last, after rewriting.
-  if (dupli_)
+  if (dupli_) {
+    dupli_->RenumberValues();
     intervals_.push_back(dupli_);
+  }
 
   // FIXME: *Calculate spill weights, allocation hints, and register classes for
   // firstInterval..