mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 19:25:00 +00:00
Dead PHI instructions need to be handled specially.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -414,6 +414,12 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
|
|||||||
while (P != FirstNonPHI && P->getOpcode() == TargetInstrInfo::PHI) {
|
while (P != FirstNonPHI && P->getOpcode() == TargetInstrInfo::PHI) {
|
||||||
unsigned DestReg = P->getOperand(0).getReg();
|
unsigned DestReg = P->getOperand(0).getReg();
|
||||||
|
|
||||||
|
// Don't both doing PHI elimination for dead PHI's.
|
||||||
|
if (P->registerDefIsDead(DestReg)) {
|
||||||
|
++P;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LiveInterval& PI = LI.getOrCreateInterval(DestReg);
|
LiveInterval& PI = LI.getOrCreateInterval(DestReg);
|
||||||
unsigned pIdx = LI.getInstructionIndex(FirstNonPHI);
|
unsigned pIdx = LI.getInstructionIndex(FirstNonPHI);
|
||||||
VNInfo* PVN = PI.getLiveRangeContaining(pIdx)->valno;
|
VNInfo* PVN = PI.getLiveRangeContaining(pIdx)->valno;
|
||||||
@@ -911,6 +917,22 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
|
|
||||||
for (std::vector<MachineInstr*>::iterator I = phis.begin(), E = phis.end();
|
for (std::vector<MachineInstr*>::iterator I = phis.begin(), E = phis.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
|
// If this is a dead PHI node, then remove it from LiveIntervals.
|
||||||
|
unsigned DestReg = (*I)->getOperand(0).getReg();
|
||||||
|
if ((*I)->registerDefIsDead(DestReg)) {
|
||||||
|
LiveInterval& PI = LI.getInterval(DestReg);
|
||||||
|
|
||||||
|
if (PI.containsOneValue()) {
|
||||||
|
LI.removeInterval(DestReg);
|
||||||
|
} else {
|
||||||
|
MachineBasicBlock::iterator PIter = *I;
|
||||||
|
while (PIter->getOpcode() == TargetInstrInfo::PHI) ++PIter;
|
||||||
|
unsigned idx = LI.getInstructionIndex(PIter);
|
||||||
|
|
||||||
|
PI.removeRange(*PI.getLiveRangeContaining(idx), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LI.RemoveMachineInstrFromMaps(*I);
|
LI.RemoveMachineInstrFromMaps(*I);
|
||||||
(*I)->eraseFromParent();
|
(*I)->eraseFromParent();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user