Fix how livein live intervals are handled. Previously it could end at MBB start....
authorEvan Cheng <evan.cheng@apple.com>
Thu, 5 Mar 2009 03:34:26 +0000 (03:34 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 5 Mar 2009 03:34:26 +0000 (03:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66129 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp

index 985a3fa16342366955d42912ea4109318b998041..c70cbb487838fc8e785b23f276f11db17912c2ee 100644 (file)
@@ -684,11 +684,13 @@ void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB,
          getInstructionFromIndex(baseIndex) == 0)
     baseIndex += InstrSlots::NUM;
   unsigned end = baseIndex;
+  bool SeenDefUse = false;
   
   while (mi != MBB->end()) {
     if (mi->killsRegister(interval.reg, tri_)) {
       DOUT << " killed";
       end = getUseIndex(baseIndex) + 1;
+      SeenDefUse = true;
       goto exit;
     } else if (mi->modifiesRegister(interval.reg, tri_)) {
       // Another instruction redefines the register before it is ever read.
@@ -697,19 +699,22 @@ void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB,
       // [defSlot(def), defSlot(def)+1)
       DOUT << " dead";
       end = getDefIndex(start) + 1;
+      SeenDefUse = true;
       goto exit;
     }
 
     baseIndex += InstrSlots::NUM;
-    while (baseIndex / InstrSlots::NUM < i2miMap_.size() && 
-           getInstructionFromIndex(baseIndex) == 0)
-      baseIndex += InstrSlots::NUM;
     ++mi;
+    if (mi != MBB->end()) {
+      while (baseIndex / InstrSlots::NUM < i2miMap_.size() && 
+             getInstructionFromIndex(baseIndex) == 0)
+        baseIndex += InstrSlots::NUM;
+    }
   }
 
 exit:
   // Live-in register might not be used at all.
-  if (end == MIIdx) {
+  if (!SeenDefUse) {
     if (isAlias) {
       DOUT << " dead";
       end = getDefIndex(MIIdx) + 1;