[llvm] c46546b - Reland "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological""

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 13 05:45:32 PDT 2021


Author: Roman Lebedev
Date: 2021-08-13T15:45:03+03:00
New Revision: c46546bd521b7c3f98a1620c9227e80dc94a5a3c

URL: https://github.com/llvm/llvm-project/commit/c46546bd521b7c3f98a1620c9227e80dc94a5a3c
DIFF: https://github.com/llvm/llvm-project/commit/c46546bd521b7c3f98a1620c9227e80dc94a5a3c.diff

LOG: Reland "[NFCI][SimplifyCFG] simplifyCondBranch(): assert that branch is non-tautological""

The commit originally unearthed a problem, reported as
https://reviews.llvm.org/rGf30a7dff8a5b32919951dcbf92e4a9d56c4679ff#1019890
Now that the problem has been fixed, and the assertion no longer fires,
let's see if there are other cases it fires on.

This reverts commit 5c8c24d2decae4a76047777271d60411fc3316eb,
relanding commit f30a7dff8a5b32919951dcbf92e4a9d56c4679ff.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index c9d4641fd6dd..847fdd760d2f 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6394,6 +6394,11 @@ static BasicBlock *allPredecessorsComeFromSameSource(BasicBlock *BB) {
 }
 
 bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
+  assert(
+      !isa<ConstantInt>(BI->getCondition()) &&
+      BI->getSuccessor(0) != BI->getSuccessor(1) &&
+      "Tautological conditional branch should have been eliminated already.");
+
   BasicBlock *BB = BI->getParent();
   if (!Options.SimplifyCondBranch)
     return false;


        


More information about the llvm-commits mailing list