Avoid comparing invalid slot indexes.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 3 Mar 2011 04:23:52 +0000 (04:23 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 3 Mar 2011 04:23:52 +0000 (04:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126922 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveInterval.cpp

index a37296f77b06bce6a11bc12bf05e1a56e53a0eaa..f2345bc2c58711b9af1f4d1b3132d4e8f8fde055 100644 (file)
@@ -33,16 +33,18 @@ using namespace llvm;
 // CompEnd - Compare LiveRange ends.
 namespace {
 struct CompEnd {
-  bool operator()(const LiveRange &A, const LiveRange &B) const {
-    return A.end < B.end;
+  bool operator()(SlotIndex A, const LiveRange &B) const {
+    return A < B.end;
+  }
+  bool operator()(const LiveRange &A, SlotIndex B) const {
+    return A.end < B;
   }
 };
 }
 
 LiveInterval::iterator LiveInterval::find(SlotIndex Pos) {
   assert(Pos.isValid() && "Cannot search for an invalid index");
-  return std::upper_bound(begin(), end(), LiveRange(SlotIndex(), Pos, 0),
-                          CompEnd());
+  return std::upper_bound(begin(), end(), Pos, CompEnd());
 }
 
 /// killedInRange - Return true if the interval has kills in [Start,End).