mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 06:33:21 +00:00
Don't crash on: X = phi (X, X).
This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22232 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bff44407e8
commit
0289929c62
@ -1461,12 +1461,15 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
BasicBlock::iterator AfterPHIIt = BB->begin();
|
||||
while (isa<PHINode>(AfterPHIIt)) {
|
||||
PHINode *PN = cast<PHINode>(AfterPHIIt++);
|
||||
if (PN->getIncomingValue(0) == PN->getIncomingValue(1))
|
||||
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||
else if (!DominatesMergePoint(PN->getIncomingValue(0), BB,
|
||||
&AggressiveInsts) ||
|
||||
!DominatesMergePoint(PN->getIncomingValue(1), BB,
|
||||
&AggressiveInsts)) {
|
||||
if (PN->getIncomingValue(0) == PN->getIncomingValue(1)) {
|
||||
if (PN->getIncomingValue(0) != PN)
|
||||
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||
else
|
||||
PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
|
||||
} else if (!DominatesMergePoint(PN->getIncomingValue(0), BB,
|
||||
&AggressiveInsts) ||
|
||||
!DominatesMergePoint(PN->getIncomingValue(1), BB,
|
||||
&AggressiveInsts)) {
|
||||
CanPromote = false;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user