summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-25 23:14:19 +0000
committerChris Lattner <sabre@nondot.org>2003-04-25 23:14:19 +0000
commitef8c8332b1307c27491c1a783c1fe520fec94170 (patch)
tree3f87036bf037750d593dca269f1673d8a1de2625 /llvm/lib/VMCore
parentb68a34eb3fe6817f9e1a745f1795a38fd48afb52 (diff)
downloadbcm5719-llvm-ef8c8332b1307c27491c1a783c1fe520fec94170.tar.gz
bcm5719-llvm-ef8c8332b1307c27491c1a783c1fe520fec94170.zip
Fix a bug that occurred when removing the last predecessor INTO an
infinite loop llvm-svn: 5953
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/BasicBlock.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp
index 04f4e1cfc0d..d04e5546162 100644
--- a/llvm/lib/VMCore/BasicBlock.cpp
+++ b/llvm/lib/VMCore/BasicBlock.cpp
@@ -186,7 +186,11 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) {
// If the PHI _HAD_ two uses, replace PHI node with its now *single* value
if (max_idx == 2) {
- PN->replaceAllUsesWith(PN->getOperand(0));
+ if (PN->getOperand(0) != PN)
+ PN->replaceAllUsesWith(PN->getOperand(0));
+ else
+ // We are left with an infinite loop with no entries: kill the PHI.
+ PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
getInstList().pop_front(); // Remove the PHI node
}
OpenPOWER on IntegriCloud