mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Replace a broken LiveInterval::MergeValueInAsValue() with something simpler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127960 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -495,60 +495,19 @@ void LiveInterval::MergeRangesInAsValue(const LiveInterval &RHS,
|
|||||||
void LiveInterval::MergeValueInAsValue(
|
void LiveInterval::MergeValueInAsValue(
|
||||||
const LiveInterval &RHS,
|
const LiveInterval &RHS,
|
||||||
const VNInfo *RHSValNo, VNInfo *LHSValNo) {
|
const VNInfo *RHSValNo, VNInfo *LHSValNo) {
|
||||||
SmallVector<VNInfo*, 4> ReplacedValNos;
|
// TODO: Make this more efficient.
|
||||||
iterator IP = begin();
|
iterator InsertPos = begin();
|
||||||
for (const_iterator I = RHS.begin(), E = RHS.end(); I != E; ++I) {
|
for (const_iterator I = RHS.begin(), E = RHS.end(); I != E; ++I) {
|
||||||
assert(I->valno == RHS.getValNumInfo(I->valno->id) && "Bad VNInfo");
|
|
||||||
if (I->valno != RHSValNo)
|
if (I->valno != RHSValNo)
|
||||||
continue;
|
continue;
|
||||||
SlotIndex Start = I->start, End = I->end;
|
|
||||||
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) {
|
|
||||||
if (IP[-1].valno != LHSValNo) {
|
|
||||||
ReplacedValNos.push_back(IP[-1].valno);
|
|
||||||
IP[-1].valno = LHSValNo; // Update val#.
|
|
||||||
}
|
|
||||||
Start = IP[-1].end;
|
|
||||||
// Trimmed away the whole range?
|
|
||||||
if (Start >= End) continue;
|
|
||||||
}
|
|
||||||
// If the end of this range overlaps with an existing liverange, trim it.
|
|
||||||
if (IP != end() && End > IP->start) {
|
|
||||||
if (IP->valno != LHSValNo) {
|
|
||||||
ReplacedValNos.push_back(IP->valno);
|
|
||||||
IP->valno = LHSValNo; // Update val#.
|
|
||||||
}
|
|
||||||
End = IP->start;
|
|
||||||
// If this trimmed away the whole range, ignore it.
|
|
||||||
if (Start == End) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map the valno in the other live range to the current live range.
|
// Map the valno in the other live range to the current live range.
|
||||||
IP = addRangeFrom(LiveRange(Start, End, LHSValNo), IP);
|
LiveRange Tmp = *I;
|
||||||
}
|
Tmp.valno = LHSValNo;
|
||||||
|
InsertPos = addRangeFrom(Tmp, InsertPos);
|
||||||
|
|
||||||
SmallSet<VNInfo*, 4> Seen;
|
|
||||||
for (unsigned i = 0, e = ReplacedValNos.size(); i != e; ++i) {
|
|
||||||
VNInfo *V1 = ReplacedValNos[i];
|
|
||||||
if (Seen.insert(V1)) {
|
|
||||||
bool isDead = true;
|
|
||||||
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
|
||||||
if (I->valno == V1) {
|
|
||||||
isDead = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (isDead) {
|
|
||||||
// Now that V1 is dead, remove it.
|
|
||||||
markValNoForDeletion(V1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// MergeValueNumberInto - This method is called when two value nubmers
|
/// MergeValueNumberInto - This method is called when two value nubmers
|
||||||
/// are found to be equivalent. This eliminates V1, replacing all
|
/// are found to be equivalent. This eliminates V1, replacing all
|
||||||
/// LiveRanges with the V1 value number with the V2 value number. This can
|
/// LiveRanges with the V1 value number with the V2 value number. This can
|
||||||
|
Reference in New Issue
Block a user