Add a new LiveInterval::overlaps(). It checks if the live interval overlaps a range...
authorEvan Cheng <evan.cheng@apple.com>
Sat, 18 Apr 2009 08:52:15 +0000 (08:52 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 18 Apr 2009 08:52:15 +0000 (08:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69434 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c75d5947b962904ceac6bb49d8abf9d634af8d84..00b51a16f1ea381738f2af774cb404585a022576 100644 (file)
@@ -379,6 +379,10 @@ namespace llvm {
       return overlapsFrom(other, other.begin());
     }
 
+    /// overlaps - Return true if the live interval overlaps a range specified
+    /// by [Start, End).
+    bool overlaps(unsigned Start, unsigned End) const;
+
     /// overlapsFrom - Return true if the intersection of the two live intervals
     /// is not empty.  The specified iterator is a hint that we can begin
     /// scanning the Other interval starting at I.
index 3f8714085aef64b6d0b7a8936fad286c1586ed5a..68d9ad4b3e658fd2a43311a0550c7a9bcc372442 100644 (file)
@@ -123,6 +123,22 @@ bool LiveInterval::overlapsFrom(const LiveInterval& other,
   return false;
 }
 
+/// overlaps - Return true if the live interval overlaps a range specified
+/// by [Start, End).
+bool LiveInterval::overlaps(unsigned Start, unsigned End) const {
+  assert(Start < End && "Invalid range");
+  const_iterator I  = begin();
+  const_iterator E  = end();
+  const_iterator si = std::upper_bound(I, E, Start);
+  const_iterator ei = std::upper_bound(I, E, End);
+  if (si != ei)
+    return true;
+  if (si == I)
+    return false;
+  --si;
+  return si->contains(Start);
+}
+
 /// extendIntervalEndTo - This method is used when we want to extend the range
 /// specified by I to end at the specified endpoint.  To do this, we should
 /// merge and eliminate all ranges that this will overlap with.  The iterator is