mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Fix bug in -split-phi-edges.
When splitting an edge after a machine basic block with fall-through, we forgot to insert a jump instruction. Fix this by calling updateTerminator() on the fall-through block when relevant. Also be more precise in PHIElimination::isLiveIn. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -64,7 +64,6 @@ bool llvm::PHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
|
|
||||||
PHIDefs.clear();
|
PHIDefs.clear();
|
||||||
PHIKills.clear();
|
PHIKills.clear();
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
// Split critical edges to help the coalescer
|
// Split critical edges to help the coalescer
|
||||||
@@ -419,7 +418,16 @@ bool llvm::PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock &MBB,
|
|||||||
LiveVariables &LV) {
|
LiveVariables &LV) {
|
||||||
LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
|
LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
|
||||||
|
|
||||||
return VI.AliveBlocks.test(MBB.getNumber()) || VI.findKill(&MBB);
|
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 *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
|
||||||
@@ -436,9 +444,12 @@ MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
|
|||||||
<< " -- BB#" << B->getNumber() << '\n');
|
<< " -- BB#" << B->getNumber() << '\n');
|
||||||
|
|
||||||
A->ReplaceUsesOfBlockWith(B, NMBB);
|
A->ReplaceUsesOfBlockWith(B, NMBB);
|
||||||
NMBB->addSuccessor(B);
|
// If A may fall through to B, we may have to insert a branch.
|
||||||
|
if (A->isLayoutSuccessor(B))
|
||||||
|
A->updateTerminator();
|
||||||
|
|
||||||
// Insert unconditional "jump B" instruction in NMBB.
|
// Insert unconditional "jump B" instruction in NMBB.
|
||||||
|
NMBB->addSuccessor(B);
|
||||||
SmallVector<MachineOperand, 4> Cond;
|
SmallVector<MachineOperand, 4> Cond;
|
||||||
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
|
MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user