Avoid comparing invalid slot indexes, and assert that it doesn't happen.
[oota-llvm.git] / lib / CodeGen / SimpleRegisterCoalescing.cpp
index 2843c1a5b6d8b2b530bb7309fd5a2a4303edd7ee..74898c210a4f854d633ef308496714d0eae35ed1 100644 (file)
@@ -1568,9 +1568,7 @@ SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start,
       if (UseMI->isIdentityCopy())
         continue;
       SlotIndex Idx = li_->getInstructionIndex(UseMI);
-      // FIXME: Should this be Idx != UseIdx? SlotIndex() will return something
-      // that compares higher than any other interval.
-      if (Idx >= Start && Idx < End && Idx >= UseIdx) {
+      if (Idx >= Start && Idx < End && (!UseIdx.isValid() || Idx >= UseIdx)) {
         LastUse = &Use;
         UseIdx = Idx.getUseIndex();
       }