[llvm] r223876 - LiveInterval: Add a 'covers' operation to LiveRange.
Matthias Braun
matze at braunis.de
Tue Dec 9 17:12:07 PST 2014
Author: matze
Date: Tue Dec 9 19:12:06 2014
New Revision: 223876
URL: http://llvm.org/viewvc/llvm-project?rev=223876&view=rev
Log:
LiveInterval: Add a 'covers' operation to LiveRange.
Modified:
llvm/trunk/include/llvm/CodeGen/LiveInterval.h
llvm/trunk/lib/CodeGen/LiveInterval.cpp
Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=223876&r1=223875&r2=223876&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Dec 9 19:12:06 2014
@@ -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).
Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=223876&r1=223875&r2=223876&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Dec 9 19:12:06 2014
@@ -185,6 +185,27 @@ bool LiveRange::overlaps(SlotIndex Start
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
More information about the llvm-commits
mailing list