Author: evancheng
Date: Tue Feb 12 20:48:26 2008
New Revision: 47044

URL: http://llvm.org/viewvc/llvm-project?rev=47044&view=rev
Log:
- Added removeValNo() to remove all live ranges of a particular value#.
- removeRange() can now update value# information.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveInterval.h
    llvm/trunk/lib/CodeGen/LiveInterval.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=47044&r1=47043&r2=47044&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Feb 12 20:48:26 2008
@@ -299,12 +299,6 @@
     /// contains the specified index, or end() if there is none.
     iterator FindLiveRangeContaining(unsigned Idx);
     
-    /// getOverlapingRanges - Given another live interval which is defined as a
-    /// copy from this one, return a list of all of the live ranges where the
-    /// two overlap and have different value numbers.
-    void getOverlapingRanges(const LiveInterval &Other, unsigned CopyIdx,
-                             std::vector<LiveRange*> &Ranges);
-
     /// overlaps - Return true if the intersection of the two live intervals is
     /// not empty.
     bool overlaps(const LiveInterval& other) const {
@@ -332,12 +326,16 @@
 
     /// removeRange - Remove the specified range from this interval.  Note that
     /// the range must already be in this interval in its entirety.
-    void removeRange(unsigned Start, unsigned End);
+    void removeRange(unsigned Start, unsigned End, bool RemoveDeadValNo = 
false);
 
-    void removeRange(LiveRange LR) {
-      removeRange(LR.start, LR.end);
+    void removeRange(LiveRange LR, bool RemoveDeadValNo = false) {
+      removeRange(LR.start, LR.end, RemoveDeadValNo);
     }
 
+    /// removeValNo - Remove all the ranges defined by the specified value#.
+    /// Also remove the value# from value# list.
+    void removeValNo(VNInfo *ValNo);
+
     /// getSize - Returns the sum of sizes of all the LiveRange's.
     ///
     unsigned getSize() const;

Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=47044&r1=47043&r2=47044&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Feb 12 20:48:26 2008
@@ -225,7 +225,8 @@
 
 /// removeRange - Remove the specified range from this interval.  Note that
 /// the range must already be in this interval in its entirety.
-void LiveInterval::removeRange(unsigned Start, unsigned End) {
+void LiveInterval::removeRange(unsigned Start, unsigned End,
+                               bool RemoveDeadValNo) {
   // Find the LiveRange containing this span.
   Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start);
   assert(I != ranges.begin() && "Range is not in interval!");
@@ -234,9 +235,34 @@
          "Range is not entirely in interval!");
 
   // If the span we are removing is at the start of the LiveRange, adjust it.
+  VNInfo *ValNo = I->valno;
   if (I->start == Start) {
     if (I->end == End) {
       removeKills(I->valno, Start, End);
+      if (RemoveDeadValNo) {
+        // Check if val# is dead.
+        bool isDead = true;
+        for (const_iterator II = begin(), EE = end(); II != EE; ++II)
+          if (II != I && II->valno == ValNo) {
+            isDead = false;
+            break;
+          }          
+        if (isDead) {
+          // Now that ValNo is dead, remove it.  If it is the largest value
+          // number, just nuke it (and any other deleted values neighboring 
it),
+          // otherwise mark it as ~1U so it can be nuked later.
+          if (ValNo->id == getNumValNums()-1) {
+            do {
+              VNInfo *VNI = valnos.back();
+              valnos.pop_back();
+              VNI->~VNInfo();
+            } while (!valnos.empty() && valnos.back()->def == ~1U);
+          } else {
+            ValNo->def = ~1U;
+          }
+        }
+      }
+
       ranges.erase(I);  // Removed the whole LiveRange.
     } else
       I->start = End;
@@ -246,7 +272,7 @@
   // Otherwise if the span we are removing is at the end of the LiveRange,
   // adjust the other way.
   if (I->end == End) {
-    removeKills(I->valno, Start, End);
+    removeKills(ValNo, Start, End);
     I->end = Start;
     return;
   }
@@ -256,9 +282,34 @@
   I->end = Start;   // Trim the old interval.
 
   // Insert the new one.
-  ranges.insert(next(I), LiveRange(End, OldEnd, I->valno));
+  ranges.insert(next(I), LiveRange(End, OldEnd, ValNo));
 }
 
+/// removeValNo - Remove all the ranges defined by the specified value#.
+/// Also remove the value# from value# list.
+void LiveInterval::removeValNo(VNInfo *ValNo) {
+  if (empty()) return;
+  Ranges::iterator I = ranges.end();
+  Ranges::iterator E = ranges.begin();
+  do {
+    --I;
+    if (I->valno == ValNo)
+      ranges.erase(I);
+  } while (I != E);
+  // Now that ValNo is dead, remove it.  If it is the largest value
+  // number, just nuke it (and any other deleted values neighboring it),
+  // otherwise mark it as ~1U so it can be nuked later.
+  if (ValNo->id == getNumValNums()-1) {
+    do {
+      VNInfo *VNI = valnos.back();
+      valnos.pop_back();
+      VNI->~VNInfo();
+    } while (!valnos.empty() && valnos.back()->def == ~1U);
+  } else {
+    ValNo->def = ~1U;
+  }
+}
+ 
 /// getLiveRangeContaining - Return the live range that contains the
 /// specified index, or null if there is none.
 LiveInterval::const_iterator 
@@ -445,7 +496,7 @@
             VNInfo *VNI = valnos.back();
             valnos.pop_back();
             VNI->~VNInfo();
-          } while (valnos.back()->def == ~1U);
+          } while (!valnos.empty() && valnos.back()->def == ~1U);
         } else {
           V1->def = ~1U;
         }
@@ -624,15 +675,18 @@
         else
           OS << vni->def;
         unsigned ee = vni->kills.size();
-        if (ee) {
+        if (ee || vni->hasPHIKill) {
           OS << "-(";
           for (unsigned j = 0; j != ee; ++j) {
             OS << vni->kills[j];
             if (j != ee-1)
               OS << " ";
           }
-          if (vni->hasPHIKill)
-            OS << " phi";
+          if (vni->hasPHIKill) {
+            if (ee)
+              OS << " ";
+            OS << "phi";
+          }
           OS << ")";
         }
       }


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

Reply via email to