summaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2006-11-01 22:26:43 +0000
committerDevang Patel <dpatel@apple.com>2006-11-01 22:26:43 +0000
commit2c0565f8e0a2306d3ea746722113ace2a53921c8 (patch)
treee1be052f3e7de0383eb5b109ec3a6e4d3181eac8 /lib/Transforms
parentdba4aeaef151c41315604c0a7b8883fc373c7fa2 (diff)
downloadexternal_llvm-2c0565f8e0a2306d3ea746722113ace2a53921c8.zip
external_llvm-2c0565f8e0a2306d3ea746722113ace2a53921c8.tar.gz
external_llvm-2c0565f8e0a2306d3ea746722113ace2a53921c8.tar.bz2
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
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/CondPropagate.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp
index 5eb5abd..d7aa7ec 100644
--- a/lib/Transforms/Scalar/CondPropagate.cpp
+++ b/lib/Transforms/Scalar/CondPropagate.cpp
@@ -196,11 +196,15 @@ void CondProp::RevectorBlockTo(BasicBlock *FromBB, BasicBlock *ToBB) {
// Get the old block we are threading through.
BasicBlock *OldSucc = FromBr->getSuccessor(0);
- // ToBB should not have any PHI nodes in it to update, because OldSucc had
- // multiple successors. If OldSucc had multiple successor and ToBB had
- // multiple predecessors, the edge between them would be critical, which we
- // already took care of.
- assert(!isa<PHINode>(ToBB->begin()) && "Critical Edge Found!");
+ // OldSucc had multiple successors. If ToBB has multiple predecessors, the
+ // edge between them would be critical, which we already took care of.
+ // If ToBB has single operand PHI node than take care of it here.
+ if (isa<PHINode>(ToBB->begin())) {
+ 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.
OldSucc->removePredecessor(FromBB);