mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 04:31:08 +00:00
Handle single-entry PHI nodes correctly. This fixes PR877 and
Transforms/CondProp/2006-08-14-SingleEntryPhiCrash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a7174736fa
commit
df32aac51b
@ -87,8 +87,18 @@ void CondProp::SimplifyBlock(BasicBlock *BB) {
|
||||
// If this block ends with an unconditional branch and the only successor has
|
||||
// only this block as a predecessor, merge the two blocks together.
|
||||
if (BranchInst *BI = dyn_cast<BranchInst>(BB->getTerminator()))
|
||||
if (BI->isUnconditional() && BI->getSuccessor(0)->getSinglePredecessor()) {
|
||||
if (BI->isUnconditional() && BI->getSuccessor(0)->getSinglePredecessor() &&
|
||||
BB != BI->getSuccessor(0)) {
|
||||
BasicBlock *Succ = BI->getSuccessor(0);
|
||||
|
||||
// If Succ has any PHI nodes, they are all single-entry PHI's.
|
||||
while (PHINode *PN = dyn_cast<PHINode>(Succ->begin())) {
|
||||
assert(PN->getNumIncomingValues() == 1 &&
|
||||
"PHI doesn't match parent block");
|
||||
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||
PN->eraseFromParent();
|
||||
}
|
||||
|
||||
// Remove BI.
|
||||
BI->eraseFromParent();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user