Skip to content

Commit 6810b9e

Browse files
committed
[LVer][profcheck] explicitly set unknown branch weights for the versioned/unversioned selector
1 parent cf0c129 commit 6810b9e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Transforms/Utils/LoopVersioning.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "llvm/IR/Dominators.h"
2424
#include "llvm/IR/MDBuilder.h"
2525
#include "llvm/IR/PassManager.h"
26+
#include "llvm/IR/ProfDataUtils.h"
2627
#include "llvm/Support/CommandLine.h"
2728
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
2829
#include "llvm/Transforms/Utils/Cloning.h"
@@ -109,8 +110,12 @@ void LoopVersioning::versionLoop(
109110
// Insert the conditional branch based on the result of the memchecks.
110111
Instruction *OrigTerm = RuntimeCheckBB->getTerminator();
111112
Builder.SetInsertPoint(OrigTerm);
112-
Builder.CreateCondBr(RuntimeCheck, NonVersionedLoop->getLoopPreheader(),
113+
auto *BI = Builder.CreateCondBr(RuntimeCheck, NonVersionedLoop->getLoopPreheader(),
113114
VersionedLoop->getLoopPreheader());
115+
// We don't know what the probability of executing the versioned vs the
116+
// unversioned variants is.
117+
setExplicitlyUnknownBranchWeightsIfProfiled(
118+
*BI, *BI->getParent()->getParent(), DEBUG_TYPE);
114119
OrigTerm->eraseFromParent();
115120

116121
// The loops merge in the original exit block. This is now dominated by the

0 commit comments

Comments
 (0)