[llvm-commits] [llvm] r85599 - in /llvm/trunk/lib/CodeGen: SimpleRegisterCoalescing.cpp SimpleRegisterCoalescing.h

Lang Hames lhames at gmail.com
Fri Oct 30 11:12:10 PDT 2009


Author: lhames
Date: Fri Oct 30 13:12:09 2009
New Revision: 85599

URL: http://llvm.org/viewvc/llvm-project?rev=85599&view=rev
Log:
Stop the iterator in ValueLiveAt from potentially running off the end of the interval.

Modified:
    llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
    llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=85599&r1=85598&r2=85599&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Fri Oct 30 13:12:09 2009
@@ -1866,8 +1866,10 @@
 /// iterator, or any subsequent range with the same value number,
 /// is live at the given point.
 bool SimpleRegisterCoalescing::ValueLiveAt(LiveInterval::iterator LRItr,
+                                           LiveInterval::iterator LREnd,
                                            LiveIndex defPoint) const {
-  for (const VNInfo *valno = LRItr->valno; LRItr->valno == valno; ++LRItr) {
+  for (const VNInfo *valno = LRItr->valno;
+       (LRItr != LREnd) && (LRItr->valno == valno); ++LRItr) {
     if (LRItr->contains(defPoint))
       return true;
   }
@@ -1922,7 +1924,7 @@
         if (!RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg))
           return false;    // Nope, bail out.
 
-        if (ValueLiveAt(LHSIt, RHSIt->valno->def))
+        if (ValueLiveAt(LHSIt, LHS.end(), RHSIt->valno->def))
           // Here is an interesting situation:
           // BB1:
           //   vr1025 = copy vr1024
@@ -1960,7 +1962,7 @@
           // Otherwise, if this is a copy from the RHS, mark it as being merged
           // in.
           if (RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) {
-            if (ValueLiveAt(LHSIt, RHSIt->valno->def))
+            if (ValueLiveAt(LHSIt, LHS.end(), RHSIt->valno->def))
               // Here is an interesting situation:
               // BB1:
               //   vr1025 = copy vr1024

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=85599&r1=85598&r2=85599&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Fri Oct 30 13:12:09 2009
@@ -204,7 +204,8 @@
     /// ValueLiveAt - Return true if the LiveRange pointed to by the given
     /// iterator, or any subsequent range with the same value number,
     /// is live at the given point.
-    bool ValueLiveAt(LiveInterval::iterator LRItr, LiveIndex defPoint) const;
+    bool ValueLiveAt(LiveInterval::iterator LRItr, LiveInterval::iterator LREnd, 
+                     LiveIndex defPoint) const;                                  
 
     /// RangeIsDefinedByCopyFromReg - Return true if the specified live range of
     /// the specified live interval is defined by a copy from the specified





More information about the llvm-commits mailing list