Use getMBBEndIdx rather than assuming that the end is right after the last instructio...
[oota-llvm.git] / lib / CodeGen / SimpleRegisterCoalescing.cpp
index ed295ac00713cca457706d7008d7c54caa8b22d7..bc833633ed24f05cb43fa5458e1605b02ee6e3b3 100644 (file)
@@ -443,7 +443,7 @@ bool SimpleRegisterCoalescing::isBackEdgeCopy(MachineInstr *CopyMI,
     LI.FindLiveRangeContaining(li_->getDefIndex(DefIdx));
   if (DstLR == LI.end())
     return false;
-  unsigned KillIdx = li_->getInstructionIndex(&MBB->back()) + InstrSlots::NUM;
+  unsigned KillIdx = li_->getMBBEndIdx(MBB) + 1;
   if (DstLR->valno->kills.size() == 1 &&
       DstLR->valno->kills[0] == KillIdx && DstLR->valno->hasPHIKill)
     return true;