Open llvmbot opened 2 years ago
This one should be the fix: https://reviews.llvm.org/D112693
UPD: indeed, Phi appears there after it's created by
// Otherwise, if there are multiple predecessors, insert a PHI that merges
// in the constant and simplify the block result. Subsequent passes of
// simplifycfg will thread the block.
if (BlockIsSimpleEnoughToThreadThrough(BB)) {
Looks like this one and the following one "tryWidenCondBranchToCondBranch" keep undoing one another.
I'm certain that FoldCondBranchOnPHI has nothing to do with this bug, at least because this test has no phis.
Dima, I am confused. What test are you referring?
Summary: we removed one BB and after 1 iteration we created it.
Investigated this bug and found out that there is a looping of the form: 1-st Iteration:
br i1 undef, label %zero.critedge, label %bci_89.us589.preheader.split ---> br i1 undef, label %zero, label %bci_89.us589.preheader.split
zero.critedge: ---> remove
br label %zero
zero: ; preds = %zero.critedge, %bci_89.us ---> zero: ; preds = %"static void FuzzerUtils.init(jobject, jfloat)541743.exit.split", %bci_89.us
2-nd Iteration:
bci_89.us: ; preds = %"static jobject java.lang.invoke.Invokers$Holder.linkToTargetMethod(jobject)587833.exit" ---> bci_89.us: ; preds = %"static void FuzzerUtils.init(jobject, jfloat)541743.exit.split", %"static jobject java.lang.invoke.Invokers$Holder.linkToTargetMethod(jobject)587833.exit"
br i1 undef, label %zero, label %bci_89.us589.preheader.split ---> br i1 undef, label %bci_89.us, label %bci_89.us589.preheader.split
zero: ; preds = %"static void FuzzerUtils.init(jobject, jfloat)541743.exit.split", %bci_89.us ---> zero: ; preds = %bci_89.us
3-d Iteration:
bci_89.us: ; preds = %"static void FuzzerUtils.init(jobject, jfloat)541743.exit.split", %"static jobject java.lang.invoke.Invokers$Holder.linkToTargetMethod(jobject)587833.exit" ---> bci_89.us: ; preds = %"static jobject java.lang.invoke.Invokers$Holder.linkToTargetMethod(jobject)587833.exit"
br i1 undef, label %bci_89.us, label %bci_89.us589.preheader.split ---> br i1 undef, label %zero.critedge, label %bci_89.us589.preheader.split
create new BB ---> zero.critedge: ; preds = %"static void FuzzerUtils.init(jobject, jfloat)541743.exit.split"
br label %zero
zero: ; preds = %bci_89.us ---> zero: ; preds = %zero.critedge, %bci_89.us
clang -cc1 -triple s390x-ibm-linux -S -target-cpu arch13 -O3 -w -o /dev/null -x ir tc_crash2_aftercreduce.ll -mllvm -disable-licm-promotion -mllvm -unroll-allow-remainder=false -mllvm -unroll-count=4
_lib/Transforms/Scalar/SimplifyCFGPass.cpp:238: bool iterativelySimplifyCFG(llvm::Function&, const llvm::TargetTransformInfo&, llvm::DomTreeUpdater*, const llvm::SimplifyCFGOptions&): Assertion `IterCnt++ < 1000 && "Iterative simplification didn't converge!"' failed.
Extended Description
To reproduce: run "opt -simplifycfg -S" on the following test
Originally result was hang (and it's same in product). I've added a sanity assert and it now is failing. It happens due to infinite execution of iterativelySimplifyCFG. The IR does not change between iterations, so maybe two transforms are undoing one another.