mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Don't crash on: X = phi (X, X).
This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll llvm-svn: 22232
This commit is contained in:
parent
53d776a6fd
commit
8c76d5c957
@ -1461,9 +1461,12 @@ 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))
|
||||
if (PN->getIncomingValue(0) == PN->getIncomingValue(1)) {
|
||||
if (PN->getIncomingValue(0) != PN)
|
||||
PN->replaceAllUsesWith(PN->getIncomingValue(0));
|
||||
else if (!DominatesMergePoint(PN->getIncomingValue(0), BB,
|
||||
else
|
||||
PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
|
||||
} else if (!DominatesMergePoint(PN->getIncomingValue(0), BB,
|
||||
&AggressiveInsts) ||
|
||||
!DominatesMergePoint(PN->getIncomingValue(1), BB,
|
||||
&AggressiveInsts)) {
|
||||
|
Loading…
Reference in New Issue
Block a user