Avoid comparing invalid slot indexes, and assert that it doesn't happen.
[oota-llvm.git] / include / llvm / CodeGen / SlotIndexes.h
index 8d3b1c09335ffd99543464e3d9084249d3f6d6b5..153e520a4771052aa8e26bf606c15fda39b03cca 100644 (file)
@@ -135,6 +135,7 @@ namespace llvm {
     }
 
     IndexListEntry& entry() const {
+      assert(isValid() && "Attempt to compare reserved index.");
       return *lie.getPointer();
     }
 
@@ -530,7 +531,7 @@ namespace llvm {
     /// Returns the instruction for the given index, or null if the given
     /// index has no instruction associated with it.
     MachineInstr* getInstructionFromIndex(SlotIndex index) const {
-      return index.entry().getInstr();
+      return index.isValid() ? index.entry().getInstr() : 0;
     }
 
     /// Returns the next non-null index.