mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Handle PHINode with only one incoming value.
This fixes http://llvm.org/bugs/show_bug.cgi?id=979 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -196,11 +196,15 @@ void CondProp::RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB) {
|
|||||||
// Get the old block we are threading through.
|
// Get the old block we are threading through.
|
||||||
BasicBlock *OldSucc = FromBr->getSuccessor(0);
|
BasicBlock *OldSucc = FromBr->getSuccessor(0);
|
||||||
|
|
||||||
// ToBB should not have any PHI nodes in it to update, because OldSucc had
|
// OldSucc had multiple successors. If ToBB has multiple predecessors, the
|
||||||
// multiple successors. If OldSucc had multiple successor and ToBB had
|
// edge between them would be critical, which we already took care of.
|
||||||
// multiple predecessors, the edge between them would be critical, which we
|
// If ToBB has single operand PHI node than take care of it here.
|
||||||
// already took care of.
|
if (isa<PHINode>(ToBB->begin())) {
|
||||||
assert(!isa<PHINode>(ToBB->begin()) && "Critical Edge Found!");
|
PHINode *PN = cast<PHINode>(ToBB->begin());
|
||||||
|
assert(PN->getNumIncomingValues() == 1 && "Critical Edge Found!");
|
||||||
|
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||||
|
PN->eraseFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
// Update PHI nodes in OldSucc to know that FromBB no longer branches to it.
|
// Update PHI nodes in OldSucc to know that FromBB no longer branches to it.
|
||||||
OldSucc->removePredecessor(FromBB);
|
OldSucc->removePredecessor(FromBB);
|
||||||
|
Reference in New Issue
Block a user