diff options
author | Chris Lattner <sabre@nondot.org> | 2005-06-17 01:45:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-06-17 01:45:53 +0000 |
commit | 0289929c6212229980c9057853860ccfd3f81678 (patch) | |
tree | 1449dba3d3a97a380575317087a5e5805796455b | |
parent | bff44407e8f371298df3d31dd076a231039a7912 (diff) | |
download | external_llvm-0289929c6212229980c9057853860ccfd3f81678.zip external_llvm-0289929c6212229980c9057853860ccfd3f81678.tar.gz external_llvm-0289929c6212229980c9057853860ccfd3f81678.tar.bz2 |
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
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index ad78506..6a3b803 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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; } |