Properly remap live ranges whose end indices are the end of the function.
authorOwen Anderson <resistor@mac.com>
Fri, 25 Jul 2008 21:07:13 +0000 (21:07 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 25 Jul 2008 21:07:13 +0000 (21:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54061 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp

index 9bd003724456c1370c477cadc6be253250248a99..833cb95eb9f3029a37657dbf78bea0f7f9377602 100644 (file)
@@ -168,8 +168,12 @@ void LiveIntervals::computeNumbering() {
           LI->end = getMBBEndIdx(J->second) + 1;
         } else {
           unsigned idx = index;
-          while (!OldI2MI[index]) ++index;
-          LI->end = mi2iMap_[OldI2MI[index]] + (idx == index ? offset : 0);
+          while (index < OldI2MI.size() && !OldI2MI[index]) ++index;
+          
+          if (index != OldI2MI.size())
+            LI->end = mi2iMap_[OldI2MI[index]] + (idx == index ? offset : 0);
+          else
+            LI->end = InstrSlots::NUM * i2miMap_.size();
         }
         
         // Remap the VNInfo def index, which works the same as the
@@ -208,8 +212,13 @@ void LiveIntervals::computeNumbering() {
           } else {
             unsigned idx = index;
             while (!OldI2MI[index]) ++index;
-            vni->kills[i] = mi2iMap_[OldI2MI[index]] +
-                            (idx == index ? offset : 0);
+            while (index < OldI2MI.size() && !OldI2MI[index]) ++index;
+            
+            if (index != OldI2MI.size())
+              vni->kills[i] = mi2iMap_[OldI2MI[index]] + 
+                              (idx == index ? offset : 0);
+            else
+              vni->kills[i] = InstrSlots::NUM * i2miMap_.size();
           }
         }
       }