diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2009-11-14 00:38:13 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2009-11-14 00:38:13 +0000 |
commit | 24b027401e6cf3dc89ced0f2124e0231857abed0 (patch) | |
tree | e85c139f9860e0ead56a3f89393e11195f559bac /llvm/lib/CodeGen/PHIElimination.cpp | |
parent | 15ca009ee77c560ab1d37f7374a4c494e751754e (diff) | |
download | bcm5719-llvm-24b027401e6cf3dc89ced0f2124e0231857abed0.tar.gz bcm5719-llvm-24b027401e6cf3dc89ced0f2124e0231857abed0.zip |
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.
llvm-svn: 88728
Diffstat (limited to 'llvm/lib/CodeGen/PHIElimination.cpp')
-rw-r--r-- | llvm/lib/CodeGen/PHIElimination.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp index e42d7a5a8c5..cb0211f38d8 100644 --- a/llvm/lib/CodeGen/PHIElimination.cpp +++ b/llvm/lib/CodeGen/PHIElimination.cpp @@ -64,7 +64,6 @@ bool llvm::PHIElimination::runOnMachineFunction(MachineFunction &Fn) { PHIDefs.clear(); PHIKills.clear(); - bool Changed = false; // Split critical edges to help the coalescer @@ -419,7 +418,16 @@ bool llvm::PHIElimination::isLiveIn(unsigned Reg, const MachineBasicBlock &MBB, LiveVariables &LV) { 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, @@ -436,9 +444,12 @@ MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, << " -- BB#" << B->getNumber() << '\n'); 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. + NMBB->addSuccessor(B); SmallVector<MachineOperand, 4> Cond; MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond); |