aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/BasicBlock.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2020-11-30 10:49:40 -0500
committerSanjay Patel <spatel@rotateright.com>2020-11-30 10:51:30 -0500
commit1dc38f8cfbbc4cce12f8416a1e51d38285e6872f (patch)
treee3f3a7fa322e75f44092912a971d9f66cfbd87dc /llvm/lib/IR/BasicBlock.cpp
parente0e7bbeb545516c50a0354efc34d329453558c9c (diff)
downloadllvm-1dc38f8cfbbc4cce12f8416a1e51d38285e6872f.zip
llvm-1dc38f8cfbbc4cce12f8416a1e51d38285e6872f.tar.gz
llvm-1dc38f8cfbbc4cce12f8416a1e51d38285e6872f.tar.bz2
[IR] improve code comment/logic in removePredecessor(); NFC
This was suggested in the post-commit review of ce134da4b1.
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();
}
}
}