Skip to content

Commit f30a7df

Browse files
committed
[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological
We really shouldn't deal with a conditional branch that can be trivially constant-folded into an unconditional branch. Indeed, barring failure to trigger BB reprocessing, that should be true, so let's assert as much, and hope the assertion never fires. If it does, we have a bug to fix.
1 parent 628f63d commit f30a7df

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6394,6 +6394,11 @@ static BasicBlock *allPredecessorsComeFromSameSource(BasicBlock *BB) {
63946394
}
63956395

63966396
bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
6397+
assert(
6398+
!isa<ConstantInt>(BI->getCondition()) &&
6399+
BI->getSuccessor(0) != BI->getSuccessor(1) &&
6400+
"Tautological conditional branch should have been eliminated already.");
6401+
63976402
BasicBlock *BB = BI->getParent();
63986403
if (!Options.SimplifyCondBranch)
63996404
return false;

0 commit comments

Comments
 (0)