From c07b7fff455327fd480a4df0b66f4192cb4ca015 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 19 Jul 2004 15:16:53 +0000 Subject: [PATCH] Fix a bug that occurs when the last instruction in a range is dead llvm-svn: 15005 --- lib/CodeGen/LiveIntervals.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/LiveIntervals.cpp b/lib/CodeGen/LiveIntervals.cpp index ebf9dcd2dd1..5fa725724ac 100644 --- a/lib/CodeGen/LiveIntervals.cpp +++ b/lib/CodeGen/LiveIntervals.cpp @@ -205,12 +205,15 @@ std::vector LiveIntervals::addIntervalsForSpills( const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(li.reg); for (LiveInterval::Ranges::const_iterator - i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { unsigned index = getBaseIndex(i->first); unsigned end = getBaseIndex(i->second-1) + InstrSlots::NUM; - for (; index < end; index += InstrSlots::NUM) { + for (; index != end; index += InstrSlots::NUM) { // skip deleted instructions - while (!getInstructionFromIndex(index)) index += InstrSlots::NUM; + while (index != end && !getInstructionFromIndex(index)) + index += InstrSlots::NUM; + if (index == end) break; + MachineBasicBlock::iterator mi = getInstructionFromIndex(index); for_operand: