aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
commit02a78cf7eacf97f2c9584e29d02f77612aead35f (patch)
tree007b074d2b5f6ada1b0cb3edf0e4547b0ef60534 /lib
parent619f825640a02cb1ff84837eb911138f170c48c3 (diff)
downloadexternal_llvm-02a78cf7eacf97f2c9584e29d02f77612aead35f.zip
external_llvm-02a78cf7eacf97f2c9584e29d02f77612aead35f.tar.gz
external_llvm-02a78cf7eacf97f2c9584e29d02f77612aead35f.tar.bz2
Fix a bug that occurred when removing the last predecessor INTO an
infinite loop git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5953 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/BasicBlock.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 04f4e1c..d04e554 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/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
}