[llvm] LoopVectorize: Set branch_weight for conditional branches (PR #72450)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 11:23:57 PST 2023
================
@@ -1710,20 +1711,19 @@ void SampleProfileLoader::generateMDProfMetadata(Function &F) {
else if (OverwriteExistingWeights)
I.setMetadata(LLVMContext::MD_prof, nullptr);
} else if (!isa<IntrinsicInst>(&I)) {
- I.setMetadata(LLVMContext::MD_prof,
- MDB.createBranchWeights(
- {static_cast<uint32_t>(BlockWeights[BB])}));
+ setBranchWeights(I, {static_cast<uint32_t>(BlockWeights[BB])});
}
}
} else if (OverwriteExistingWeights || ProfileSampleBlockAccurate) {
// Set profile metadata (possibly annotated by LTO prelink) to zero or
// clear it for cold code.
for (auto &I : *BB) {
if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
- if (cast<CallBase>(I).isIndirectCall())
+ if (cast<CallBase>(I).isIndirectCall()) {
I.setMetadata(LLVMContext::MD_prof, nullptr);
----------------
WenleiHe wrote:
Didn't mean to keep asking for more, but the inconsistency in nearby code wrt dealing with setMetadata directly, vs calling setBranchWeights seem not ideal. I would add clearBranchWeights too. But not gonna block the patch because of that.
https://github.com/llvm/llvm-project/pull/72450
More information about the llvm-commits
mailing list