[PATCH] D88438: BreakCriticalEdges: bail if loop-simplify form requested for CallBr terminated BB
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 11:43:34 PDT 2020
nickdesaulniers created this revision.
nickdesaulniers added reviewers: efriedma, fhahn, void, craig.topper.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
nickdesaulniers requested review of this revision.
Otherwise we'll fail the assertion in SplitBlockPredecessors() related
to splitting the edges from CallBr's.
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1161
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88438
Files:
llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
Index: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
===================================================================
--- llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -158,22 +158,21 @@
SmallVector<BasicBlock *, 4> LoopPreds;
// Check if extra modifications will be required to preserve loop-simplify
// form after splitting. If it would require splitting blocks with IndirectBr
- // terminators, bail out if preserving loop-simplify form is requested.
+ // or CallBr terminators, bail out if preserving loop-simplify form is
+ // requested.
if (LI) {
if (Loop *TIL = LI->getLoopFor(TIBB)) {
- // The only that we can break LoopSimplify form by splitting a critical
- // edge is if after the split there exists some edge from TIL to DestBB
- // *and* the only edge into DestBB from outside of TIL is that of
+ // The only way that we can break LoopSimplify form by splitting a
+ // critical edge is if after the split there exists some edge from TIL to
+ // DestBB *and* the only edge into DestBB from outside of TIL is that of
// NewBB. If the first isn't true, then LoopSimplify still holds, NewBB
// is the new exit block and it has no non-loop predecessors. If the
// second isn't true, then DestBB was not in LoopSimplify form prior to
// the split as it had a non-loop predecessor. In both of these cases,
// the predecessor must be directly in TIL, not in a subloop, or again
// LoopSimplify doesn't hold.
- for (pred_iterator I = pred_begin(DestBB), E = pred_end(DestBB); I != E;
- ++I) {
- BasicBlock *P = *I;
+ for (BasicBlock *P : predecessors(DestBB)) {
if (P == TIBB)
continue; // The new block is known.
if (LI->getLoopFor(P) != TIL) {
@@ -186,7 +185,8 @@
// Loop-simplify form can be preserved, if we can split all in-loop
// predecessors.
if (any_of(LoopPreds, [](BasicBlock *Pred) {
- return isa<IndirectBrInst>(Pred->getTerminator());
+ const Instruction *T = Pred->getTerminator();
+ return isa<IndirectBrInst>(T) || isa<CallBrInst>(T);
})) {
if (Options.PreserveLoopSimplify)
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88438.294769.patch
Type: text/x-patch
Size: 2313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/50efca25/attachment.bin>
More information about the llvm-commits
mailing list