aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/BasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/BasicBlock.cpp')
-rw-r--r--llvm/lib/IR/BasicBlock.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 3268641..95b8602b 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -333,14 +333,16 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
Phi.removeIncomingValue(Pred, !KeepOneInputPHIs);
if (KeepOneInputPHIs)
continue;
- // If we have a single predecessor, removeIncomingValue erased the PHI
- // node itself.
+
+ // If we have a single predecessor, removeIncomingValue may have erased the
+ // PHI node itself.
+ if (NumPreds == 1)
+ continue;
+
// Try to replace the PHI node with a constant value.
- if (NumPreds > 1) {
- if (Value *PhiConstant = Phi.hasConstantValue()) {
- Phi.replaceAllUsesWith(PhiConstant);
- Phi.eraseFromParent();
- }
+ if (Value *PhiConstant = Phi.hasConstantValue()) {
+ Phi.replaceAllUsesWith(PhiConstant);
+ Phi.eraseFromParent();
}
}
}