mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-12 16:25:18 +00:00
LiveIntervalAnalysis: Mark subregister defs as undef when we determined they are only reading a dead superregister value
This was not necessary before as this case can only be detected when the liveness analysis is at subregister level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226733 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -448,23 +448,34 @@ bool LiveIntervals::computeDeadValues(LiveInterval &LI,
|
||||
for (auto VNI : LI.valnos) {
|
||||
if (VNI->isUnused())
|
||||
continue;
|
||||
LiveRange::iterator I = LI.FindSegmentContaining(VNI->def);
|
||||
SlotIndex Def = VNI->def;
|
||||
LiveRange::iterator I = LI.FindSegmentContaining(Def);
|
||||
assert(I != LI.end() && "Missing segment for VNI");
|
||||
if (I->end != VNI->def.getDeadSlot())
|
||||
|
||||
// Is the register live before? Otherwise we may have to add a read-undef
|
||||
// flag for subregister defs.
|
||||
if (MRI->tracksSubRegLiveness()) {
|
||||
if ((I == LI.begin() || std::prev(I)->end < Def) && !VNI->isPHIDef()) {
|
||||
MachineInstr *MI = getInstructionFromIndex(Def);
|
||||
MI->addRegisterDefReadUndef(LI.reg);
|
||||
}
|
||||
}
|
||||
|
||||
if (I->end != Def.getDeadSlot())
|
||||
continue;
|
||||
if (VNI->isPHIDef()) {
|
||||
// This is a dead PHI. Remove it.
|
||||
VNI->markUnused();
|
||||
LI.removeSegment(I);
|
||||
DEBUG(dbgs() << "Dead PHI at " << VNI->def << " may separate interval\n");
|
||||
DEBUG(dbgs() << "Dead PHI at " << Def << " may separate interval\n");
|
||||
PHIRemoved = true;
|
||||
} else {
|
||||
// This is a dead def. Make sure the instruction knows.
|
||||
MachineInstr *MI = getInstructionFromIndex(VNI->def);
|
||||
MachineInstr *MI = getInstructionFromIndex(Def);
|
||||
assert(MI && "No instruction defining live value");
|
||||
MI->addRegisterDead(LI.reg, TRI);
|
||||
if (dead && MI->allDefsAreDead()) {
|
||||
DEBUG(dbgs() << "All defs dead: " << VNI->def << '\t' << *MI);
|
||||
DEBUG(dbgs() << "All defs dead: " << Def << '\t' << *MI);
|
||||
dead->push_back(MI);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user