forked from OSchip/llvm-project
Fix SCTC bug when two pred/succ BB are in a loop.
Summary: It's possible that two basic blocks being conidered for SCTC are in a loop in the CFG. In this case a block that is both a predecessor and a successor may have been processed and marked invalid by a previous iteration of the SCTC loop. We should skip rewriting in this case. (cherry picked from FBD5886721)
This commit is contained in:
parent
42f957bb75
commit
aa05dc91c5
|
@ -619,6 +619,16 @@ uint64_t SimplifyConditionalTailCalls::fixTailCalls(BinaryContext &BC,
|
|||
assert(Result && "internal error analyzing conditional branch");
|
||||
assert(CondBranch && "conditional branch expected");
|
||||
|
||||
// It's possible that PredBB is also a successor to BB that may have
|
||||
// been processed by a previous iteration of the SCTC loop, in which
|
||||
// case it may have been marked invalid. We should skip rewriting in
|
||||
// this case.
|
||||
if (!PredBB->isValid()) {
|
||||
assert(PredBB->isSuccessor(BB) &&
|
||||
"PredBB should be valid if it is not a successor to BB");
|
||||
continue;
|
||||
}
|
||||
|
||||
// We don't want to reverse direction of the branch in new order
|
||||
// without further profile analysis.
|
||||
const bool DirectionFlag = CondSucc == BB ? IsForwardCTC : !IsForwardCTC;
|
||||
|
|
Loading…
Reference in New Issue