Skip to content

Commit ede2a81

Browse files
committed
Apply suggestions from code review
1 parent d2c99a5 commit ede2a81

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ static void buildPartialInvariantUnswitchConditionalBranch(
377377
IRBuilder<> IRB(&BB);
378378
IRB.SetCurrentDebugLocation(DebugLoc::getCompilerGenerated());
379379
Value *Cond = VMap[ToDuplicate[0]];
380+
// The expectation is that ToDuplicate[0] is the condition used by the
381+
// OriginalBranch, case in which we can clone the profile metadata from there.
380382
auto *ProfData =
381383
!ProfcheckDisableMetadataFixes &&
382384
ToDuplicate[0] == skipTrivialSelect(OriginalBranch.getCondition())
@@ -386,8 +388,8 @@ static void buildPartialInvariantUnswitchConditionalBranch(
386388
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
387389
Direction ? &NormalSucc : &UnswitchedSucc, ProfData);
388390
if (!ProfData)
389-
setExplicitlyUnknownBranchWeightsIfProfiled(
390-
*BR, *BR->getParent()->getParent(), DEBUG_TYPE);
391+
setExplicitlyUnknownBranchWeightsIfProfiled(*BR, *BR->getFunction(),
392+
DEBUG_TYPE);
391393
}
392394

393395
/// Rewrite the PHI nodes in an unswitched loop exit basic block.

0 commit comments

Comments
 (0)