summaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveIntervalUnion.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2010-11-09 21:04:34 +0000
committerAndrew Trick <atrick@apple.com>2010-11-09 21:04:34 +0000
commit071d1c063f1080c70a7141d947a96cf511a1ba45 (patch)
treecc1fae73b6d7fc2f8f2e69c97e3afe89b1b4ca88 /lib/CodeGen/LiveIntervalUnion.cpp
parent50a04d067f8803d52cababdabe5c188844c5c210 (diff)
downloadllvm-071d1c063f1080c70a7141d947a96cf511a1ba45.tar.gz
llvm-071d1c063f1080c70a7141d947a96cf511a1ba45.tar.bz2
llvm-071d1c063f1080c70a7141d947a96cf511a1ba45.tar.xz
Adds RABasic verification and tracing.
(retry now that the windows build is green) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118630 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveIntervalUnion.cpp')
-rw-r--r--lib/CodeGen/LiveIntervalUnion.cpp52
1 files changed, 47 insertions, 5 deletions
diff --git a/lib/CodeGen/LiveIntervalUnion.cpp b/lib/CodeGen/LiveIntervalUnion.cpp
index ec502cd51e..dccffbb98e 100644
--- a/lib/CodeGen/LiveIntervalUnion.cpp
+++ b/lib/CodeGen/LiveIntervalUnion.cpp
@@ -15,6 +15,7 @@
#define DEBUG_TYPE "regalloc"
#include "LiveIntervalUnion.h"
+#include "llvm/ADT/SparseBitVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -73,12 +74,10 @@ void LiveIntervalUnion::unify(LiveInterval &lvr) {
#ifndef NDEBUG
// check for overlap (inductively)
if (segPos != segments_.begin()) {
- SegmentIter prevPos = segPos;
- --prevPos;
- assert(prevPos->end <= segment.start && "overlapping segments" );
+ assert(llvm::prior(segPos)->end <= segment.start &&
+ "overlapping segments" );
}
- SegmentIter nextPos = segPos;
- ++nextPos;
+ SegmentIter nextPos = llvm::next(segPos);
if (nextPos != segments_.end())
assert(segment.end <= nextPos->start && "overlapping segments" );
#endif // NDEBUG
@@ -98,6 +97,49 @@ void LiveIntervalUnion::extract(const LiveInterval &lvr) {
}
}
+raw_ostream& llvm::operator<<(raw_ostream& os, const LiveSegment &ls) {
+ return os << '[' << ls.start << ',' << ls.end << ':' <<
+ ls.liveVirtReg->reg << ")";
+}
+
+void LiveSegment::dump() const {
+ dbgs() << *this << "\n";
+}
+
+void
+LiveIntervalUnion::print(raw_ostream &os,
+ const AbstractRegisterDescription *rdesc) const {
+ os << "LIU ";
+ if (rdesc != NULL)
+ os << rdesc->getName(repReg_);
+ else {
+ os << repReg_;
+ }
+ for (LiveSegments::const_iterator segI = segments_.begin(),
+ segEnd = segments_.end(); segI != segEnd; ++segI) {
+ dbgs() << " " << *segI;
+ }
+ os << "\n";
+}
+
+void LiveIntervalUnion::dump(const AbstractRegisterDescription *rdesc) const {
+ print(dbgs(), rdesc);
+}
+
+#ifndef NDEBUG
+// Verify the live intervals in this union and add them to the visited set.
+void LiveIntervalUnion::verify(LvrBitSet& visitedVRegs) {
+ SegmentIter segI = segments_.begin();
+ SegmentIter segEnd = segments_.end();
+ if (segI == segEnd) return;
+ visitedVRegs.set(segI->liveVirtReg->reg);
+ for (++segI; segI != segEnd; ++segI) {
+ visitedVRegs.set(segI->liveVirtReg->reg);
+ assert(llvm::prior(segI)->end <= segI->start && "overlapping segments" );
+ }
+}
+#endif //!NDEBUG
+
// Private interface accessed by Query.
//
// Find a pair of segments that intersect, one in the live virtual register