diff options
author | Matthias Braun <matze@braunis.de> | 2014-12-10 01:12:06 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2014-12-10 01:12:06 +0000 |
commit | e62c2070927f1304d9bfa17fb5084b01acf5e68b (patch) | |
tree | 1a3aa6ddae5b0628ab346eb6d7f336e1dca3ab91 /llvm | |
parent | e01cf6e4c0697ebece1df42288b8718a2d7dae69 (diff) | |
download | bcm5719-llvm-e62c2070927f1304d9bfa17fb5084b01acf5e68b.tar.gz bcm5719-llvm-e62c2070927f1304d9bfa17fb5084b01acf5e68b.zip |
LiveInterval: Add a 'covers' operation to LiveRange.
llvm-svn: 223876
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/CodeGen/LiveInterval.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LiveInterval.cpp | 21 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h index 9b1b65a7ae2..a936ac64255 100644 --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -405,6 +405,12 @@ namespace llvm { /// scanning the Other range starting at I. bool overlapsFrom(const LiveRange &Other, const_iterator I) const; + /// Returns true if all segments of the @p Other live range are completely + /// covered by this live range. + /// Adjacent live ranges do not affect the covering:the liverange + /// [1,5](5,10] covers (3,7]. + bool covers(const LiveRange &Other) const; + /// Add the specified Segment to this range, merging segments as /// appropriate. This returns an iterator to the inserted segment (which /// may have grown since it was inserted). diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index ddb00323b53..bacd6197808 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -185,6 +185,27 @@ bool LiveRange::overlaps(SlotIndex Start, SlotIndex End) const { return I != begin() && (--I)->end > Start; } +bool LiveRange::covers(const LiveRange &Other) const { + if (empty()) + return Other.empty(); + + const_iterator I = begin(); + for (const_iterator O = Other.begin(), OE = Other.end(); O != OE; ++O) { + I = advanceTo(I, O->start); + if (I == end() || I->start > O->start) + return false; + + // Check adjacent live segments and see if we can get behind O->end. + while (I->end < O->end) { + const_iterator Last = I; + // Get next segment and abort if it was not adjacent. + ++I; + if (I == end() || Last->end != I->start) + return false; + } + } + return true; +} /// ValNo is dead, remove it. If it is the largest value number, just nuke it /// (and any other deleted values neighboring it), otherwise mark it as ~1U so |