mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-22 09:29:31 +00:00
Simplify LiveIntervals::shrinkToUses() a bit by using the new extendInBlock().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126806 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a4d347357c
commit
e0ab24532c
@ -781,46 +781,34 @@ void LiveIntervals::shrinkToUses(LiveInterval *li) {
|
|||||||
NewLI.addRange(LiveRange(VNI->def, VNI->def.getNextSlot(), VNI));
|
NewLI.addRange(LiveRange(VNI->def, VNI->def.getNextSlot(), VNI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep track of the PHIs that are in use.
|
||||||
|
SmallPtrSet<VNInfo*, 8> UsedPHIs;
|
||||||
|
|
||||||
// Extend intervals to reach all uses in WorkList.
|
// Extend intervals to reach all uses in WorkList.
|
||||||
while (!WorkList.empty()) {
|
while (!WorkList.empty()) {
|
||||||
SlotIndex Idx = WorkList.back().first;
|
SlotIndex Idx = WorkList.back().first;
|
||||||
VNInfo *VNI = WorkList.back().second;
|
VNInfo *VNI = WorkList.back().second;
|
||||||
WorkList.pop_back();
|
WorkList.pop_back();
|
||||||
|
|
||||||
// Extend the live range for VNI to be live at Idx.
|
|
||||||
LiveInterval::iterator I = NewLI.find(Idx);
|
|
||||||
|
|
||||||
// Already got it?
|
|
||||||
if (I != NewLI.end() && I->start <= Idx) {
|
|
||||||
assert(I->valno == VNI && "Unexpected existing value number");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is there already a live range in the block containing Idx?
|
|
||||||
const MachineBasicBlock *MBB = getMBBFromIndex(Idx);
|
const MachineBasicBlock *MBB = getMBBFromIndex(Idx);
|
||||||
SlotIndex BlockStart = getMBBStartIdx(MBB);
|
SlotIndex BlockStart = getMBBStartIdx(MBB);
|
||||||
DEBUG(dbgs() << "Shrink: Use val#" << VNI->id << " at " << Idx
|
|
||||||
<< " in BB#" << MBB->getNumber() << '@' << BlockStart);
|
// Extend the live range for VNI to be live at Idx.
|
||||||
if (I != NewLI.begin() && (--I)->end > BlockStart) {
|
if (VNInfo *ExtVNI = NewLI.extendInBlock(BlockStart, Idx)) {
|
||||||
assert(I->valno == VNI && "Wrong reaching def");
|
assert(ExtVNI == VNI && "Unexpected existing value number");
|
||||||
DEBUG(dbgs() << " extend [" << I->start << ';' << I->end << ")\n");
|
// Is this a PHIDef we haven't seen before?
|
||||||
// Is this the first use of a PHIDef in its defining block?
|
if (!VNI->isPHIDef() || !UsedPHIs.insert(VNI))
|
||||||
if (VNI->isPHIDef() && I->end == VNI->def.getNextSlot()) {
|
continue;
|
||||||
// The PHI is live, make sure the predecessors are live-out.
|
// The PHI is live, make sure the predecessors are live-out.
|
||||||
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
|
for (MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(),
|
||||||
PE = MBB->pred_end(); PI != PE; ++PI) {
|
PE = MBB->pred_end(); PI != PE; ++PI) {
|
||||||
SlotIndex Stop = getMBBEndIdx(*PI).getPrevSlot();
|
SlotIndex Stop = getMBBEndIdx(*PI).getPrevSlot();
|
||||||
VNInfo *PVNI = li->getVNInfoAt(Stop);
|
VNInfo *PVNI = li->getVNInfoAt(Stop);
|
||||||
// A predecessor is not required to have a live-out value for a PHI.
|
// A predecessor is not required to have a live-out value for a PHI.
|
||||||
if (PVNI) {
|
if (PVNI) {
|
||||||
assert(PVNI->hasPHIKill() && "Missing hasPHIKill flag");
|
assert(PVNI->hasPHIKill() && "Missing hasPHIKill flag");
|
||||||
WorkList.push_back(std::make_pair(Stop, PVNI));
|
WorkList.push_back(std::make_pair(Stop, PVNI));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend the live range in the block to include Idx.
|
|
||||||
NewLI.addRange(LiveRange(I->end, Idx.getNextSlot(), VNI));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user