Avoid dereferencing end() in collectInterferingVRegs() when there is no
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 17 Dec 2010 23:16:38 +0000 (23:16 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 17 Dec 2010 23:16:38 +0000 (23:16 +0000)
interference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122108 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/LiveInterval.h
lib/CodeGen/LiveIntervalUnion.cpp

index c21df28cdd02ad65235a4511d073087b86202492..72f1624d0664d0bb4507e3ef3741c843be7f468c 100644 (file)
@@ -250,6 +250,7 @@ namespace llvm {
     /// position is in a hole, this method returns an iterator pointing to the
     /// LiveRange immediately after the hole.
     iterator advanceTo(iterator I, SlotIndex Pos) {
+      assert(I != end());
       if (Pos >= endIndex())
         return end();
       while (I->end <= Pos) ++I;
index 7ebe96f0660e9c089c9f832881ddddd2e468c2f0..cec68850fa884da856d789939e93bedb098d73c9 100644 (file)
@@ -238,7 +238,7 @@ collectInterferingVRegs(unsigned MaxInterferingRegs) {
   InterferenceResult IR = firstInterference();
   LiveInterval::iterator VirtRegEnd = VirtReg->end();
   LiveInterval *RecentInterferingVReg = NULL;
-  while (IR.LiveUnionI.valid()) {
+  if (IR.VirtRegI != VirtRegEnd) while (IR.LiveUnionI.valid()) {
     // Advance the union's iterator to reach an unseen interfering vreg.
     do {
       if (IR.LiveUnionI.value() == RecentInterferingVReg)