aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LiveInterval.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-03-11 00:03:21 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-03-11 00:03:21 +0000
commita2e6435e483f30e00382a5758f6dcc67e213b57a (patch)
treefdfebe0e7a7f9e2de6c971b2e5f62847ab01558b /lib/CodeGen/LiveInterval.cpp
parentdd446324982c1b54d6ecc756d2eff9ce37e6e5c1 (diff)
Two coalescer fixes in one.
1. Use the same value# to represent unknown values being merged into sub-registers. 2. When coalescer commute an instruction and the destination is a physical register, update its sub-registers by merging in the extended ranges. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveInterval.cpp')
-rw-r--r--lib/CodeGen/LiveInterval.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index 40f8cd4388..75cd36dec2 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -551,6 +551,20 @@ void LiveInterval::MergeValueInAsValue(const LiveInterval &RHS,
}
}
+VNInfo *LiveInterval::getUnknownValNo(BumpPtrAllocator &VNInfoAllocator) {
+ unsigned i = getNumValNums();
+ if (i) {
+ do {
+ --i;
+ VNInfo *VNI = getValNumInfo(i);
+ if (VNI->def == ~0U && !VNI->copy &&
+ !VNI->hasPHIKill && !VNI->redefByEC && VNI->kills.empty())
+ return VNI;
+ } while (i != 0);
+ }
+ return getNextValue(~0U, 0, VNInfoAllocator);
+}
+
/// MergeInClobberRanges - For any live ranges that are not defined in the
/// current interval, but are defined in the Clobbers interval, mark them
@@ -561,8 +575,7 @@ void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers,
// Find a value # to use for the clobber ranges. If there is already a value#
// for unknown values, use it.
- // FIXME: Use a single sentinal number for these!
- VNInfo *ClobberValNo = getNextValue(~0U, 0, VNInfoAllocator);
+ VNInfo *ClobberValNo = getUnknownValNo(VNInfoAllocator);
iterator IP = begin();
for (const_iterator I = Clobbers.begin(), E = Clobbers.end(); I != E; ++I) {
@@ -587,6 +600,32 @@ void LiveInterval::MergeInClobberRanges(const LiveInterval &Clobbers,
}
}
+void LiveInterval::MergeInClobberRange(unsigned Start, unsigned End,
+ BumpPtrAllocator &VNInfoAllocator) {
+ // Find a value # to use for the clobber ranges. If there is already a value#
+ // for unknown values, use it.
+ VNInfo *ClobberValNo = getUnknownValNo(VNInfoAllocator);
+
+ iterator IP = begin();
+ IP = std::upper_bound(IP, end(), Start);
+
+ // If the start of this range overlaps with an existing liverange, trim it.
+ if (IP != begin() && IP[-1].end > Start) {
+ Start = IP[-1].end;
+ // Trimmed away the whole range?
+ if (Start >= End) return;
+ }
+ // If the end of this range overlaps with an existing liverange, trim it.
+ if (IP != end() && End > IP->start) {
+ End = IP->start;
+ // If this trimmed away the whole range, ignore it.
+ if (Start == End) return;
+ }
+
+ // Insert the clobber interval.
+ addRangeFrom(LiveRange(Start, End, ClobberValNo), IP);
+}
+
/// MergeValueNumberInto - This method is called when two value nubmers
/// are found to be equivalent. This eliminates V1, replacing all
/// LiveRanges with the V1 value number with the V2 value number. This can