Skip to content

Commit cf0c129

Browse files
committed
[SLU][profcheck] Propagate profile for branches on injected conditions.
1 parent 7fb0459 commit cf0c129

File tree

2 files changed

+79
-72
lines changed

2 files changed

+79
-72
lines changed

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,10 +3195,15 @@ injectPendingInvariantConditions(NonTrivialUnswitchCandidate Candidate, Loop &L,
31953195
Builder.SetInsertPoint(TI);
31963196
auto *InvariantBr =
31973197
Builder.CreateCondBr(InjectedCond, InLoopSucc, CheckBlock);
3198+
// We don't know anything about the relation between the limits.
3199+
setExplicitlyUnknownBranchWeightsIfProfiled(
3200+
*InvariantBr, *InvariantBr->getParent()->getParent(), DEBUG_TYPE);
31983201

31993202
Builder.SetInsertPoint(CheckBlock);
3200-
Builder.CreateCondBr(TI->getCondition(), TI->getSuccessor(0),
3201-
TI->getSuccessor(1));
3203+
Builder.CreateCondBr(
3204+
TI->getCondition(), TI->getSuccessor(0), TI->getSuccessor(1),
3205+
!ProfcheckDisableMetadataFixes ? TI->getMetadata(LLVMContext::MD_prof)
3206+
: nullptr);
32023207
TI->eraseFromParent();
32033208

32043209
// Fixup phis.

0 commit comments

Comments
 (0)