aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-04-18 08:52:15 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-04-18 08:52:15 +0000
commit60c15e5295626797de6c2ba7f566c87e751485b0 (patch)
treef46920dd16a68f7ec4a67dd0611adc0af56b5c4a /lib/CodeGen
parentb866cc8f2b64f94467cbeaa252538fb696e13db8 (diff)
downloadexternal_llvm-60c15e5295626797de6c2ba7f566c87e751485b0.zip
external_llvm-60c15e5295626797de6c2ba7f566c87e751485b0.tar.gz
external_llvm-60c15e5295626797de6c2ba7f566c87e751485b0.tar.bz2
Add a new LiveInterval::overlaps(). It checks if the live interval overlaps a range specified by [Start, End).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/LiveInterval.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index 3f87140..68d9ad4 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -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