aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/BasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-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 04f4e1cfc0..d04e554616 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
}