mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-24 13:18:17 +00:00
Be more clever about calculating live variables through new basic blocks.
When splitting a critical edge, the registers live through the edge are: - Used in a PHI instruction, or - Live out from the predecessor, and - Live in to the successor. This allows the coalescer to eliminate even more phi joins. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89530 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -353,7 +353,7 @@ bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF,
|
||||
// We break edges when registers are live out from the predecessor block
|
||||
// (not considering PHI nodes). If the register is live in to this block
|
||||
// anyway, we would gain nothing from splitting.
|
||||
if (isLiveOut(Reg, *PreMBB, LV) && !isLiveIn(Reg, MBB, LV))
|
||||
if (!LV.isLiveIn(Reg, MBB) && isLiveOut(Reg, *PreMBB, LV))
|
||||
SplitCriticalEdge(PreMBB, &MBB);
|
||||
}
|
||||
}
|
||||
@@ -406,22 +406,6 @@ bool llvm::PHIElimination::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool llvm::PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock &MBB,
|
||||
LiveVariables &LV) {
|
||||
LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
|
||||
|
||||
if (VI.AliveBlocks.test(MBB.getNumber()))
|
||||
return true;
|
||||
|
||||
// defined in MBB?
|
||||
const MachineInstr *Def = MRI->getVRegDef(Reg);
|
||||
if (Def && Def->getParent() == &MBB)
|
||||
return false;
|
||||
|
||||
// killed in MBB?
|
||||
return VI.findKill(&MBB);
|
||||
}
|
||||
|
||||
MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
|
||||
MachineBasicBlock *B) {
|
||||
assert(A && B && "Missing MBB end point");
|
||||
@@ -463,7 +447,7 @@ MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
|
||||
i->getOperand(ni+1).setMBB(NMBB);
|
||||
|
||||
if (LiveVariables *LV=getAnalysisIfAvailable<LiveVariables>())
|
||||
LV->addNewBlock(NMBB, A);
|
||||
LV->addNewBlock(NMBB, A, B);
|
||||
|
||||
if (MachineDominatorTree *MDT=getAnalysisIfAvailable<MachineDominatorTree>())
|
||||
MDT->addNewBlock(NMBB, A);
|
||||
|
||||
Reference in New Issue
Block a user