diff options
| author | Andrew Trick <atrick@apple.com> | 2010-10-26 18:34:01 +0000 |
|---|---|---|
| committer | Andrew Trick <atrick@apple.com> | 2010-10-26 18:34:01 +0000 |
| commit | 84aef49e328b69c27142d0d87b220e6cc6468bf4 (patch) | |
| tree | 1391e2798525eb825690b2ee669f2096c4dd2431 /llvm/lib/CodeGen/LiveIntervalUnion.cpp | |
| parent | 6dfb484139ffaa589cd7e721450bad1f62bce6a5 (diff) | |
| download | bcm5719-llvm-84aef49e328b69c27142d0d87b220e6cc6468bf4.tar.gz bcm5719-llvm-84aef49e328b69c27142d0d87b220e6cc6468bf4.zip | |
Jakob's review of the basic register allocator.
llvm-svn: 117384
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervalUnion.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LiveIntervalUnion.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalUnion.cpp b/llvm/lib/CodeGen/LiveIntervalUnion.cpp index dea228300ec..6e2cd0fc313 100644 --- a/llvm/lib/CodeGen/LiveIntervalUnion.cpp +++ b/llvm/lib/CodeGen/LiveIntervalUnion.cpp @@ -21,6 +21,9 @@ using namespace llvm; // Merge a LiveInterval's segments. Guarantee no overlaps. +// +// Consider coalescing adjacent segments to save space, even though it makes +// extraction more complicated. void LiveIntervalUnion::unify(LiveInterval &lvr) { // Add this live virtual register to the union LiveVirtRegs::iterator pos = std::upper_bound(lvrs_.begin(), lvrs_.end(), @@ -34,19 +37,21 @@ void LiveIntervalUnion::unify(LiveInterval &lvr) { LiveSegment segment(lvrI->start, lvrI->end, lvr); segPos = segments_.insert(segPos, segment); assert(*segPos == segment && "need equal val for equal key"); +#ifndef NDEBUG + // check for overlap (inductively) + if (segPos != segments_.begin()) { + SegmentIter prevPos = segPos; + --prevPos; + assert(prevPos->end <= segment.start && "overlapping segments" ); + } + SegmentIter nextPos = segPos; + ++nextPos; + if (nextPos != segments_.end()) + assert(segment.end <= nextPos->start && "overlapping segments" ); +#endif // NDEBUG } } -namespace { - -// Keep LVRs sorted for fast membership test and extraction. -struct LessReg - : public std::binary_function<LiveInterval*, LiveInterval*, bool> { - bool operator()(const LiveInterval *left, const LiveInterval *right) const { - return left->reg < right->reg; - } -}; - // Low-level helper to find the first segment in the range [segI,segEnd) that // intersects with a live virtual register segment, or segI.start >= lvr.end // @@ -67,10 +72,8 @@ struct LessReg // Assuming intervals are disjoint, if an intersection exists, it must be the // segment found or immediately behind it. We continue reverse iterating to // return the first overlap. -// -// FIXME: support extract(), handle tombstones of extracted lvrs. typedef LiveIntervalUnion::SegmentIter SegmentIter; -SegmentIter upperBound(SegmentIter segBegin, +static SegmentIter upperBound(SegmentIter segBegin, SegmentIter segEnd, const LiveRange &lvrSeg) { assert(lvrSeg.end > segBegin->start && "segment iterator precondition"); @@ -84,7 +87,6 @@ SegmentIter upperBound(SegmentIter segBegin, } return segI; } -} // end anonymous namespace // Private interface accessed by Query. // |

