Fix a conditional so we don't access past the end of the range. Thanks to
authorChris Lattner <sabre@nondot.org>
Thu, 20 Oct 2005 22:50:10 +0000 (22:50 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 20 Oct 2005 22:50:10 +0000 (22:50 +0000)
Andrew for bringing this to my attn.

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

lib/CodeGen/LiveInterval.cpp

index 50d8a2593673f07c9b77bf8efcd6e5c2474e5261..a7f1eb357eeb2c7011381f5e7ebd97fb9211c929 100644 (file)
@@ -218,12 +218,10 @@ void LiveInterval::extendIntervalEndTo(Ranges::iterator I, unsigned NewEnd) {
   
   // If the newly formed range now touches the range after it and if they have
   // the same value number, merge the two ranges into one range.
-  if (I != ranges.end()) {
-    Ranges::iterator Next = next(I);
-    if (Next->start == I->end && Next->ValId == ValId) {
-      I->end = Next->end;
-      ranges.erase(Next);
-    }
+  Ranges::iterator Next = next(I);
+  if (Next != ranges.end() && Next->start == I->end && Next->ValId == ValId) {
+    I->end = Next->end;
+    ranges.erase(Next);
   }
 }