[llvm] [profcheck] Add indirect call metadata (PR #154657)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 18:51:43 PDT 2025
================
@@ -92,12 +97,16 @@ bool ProfileInjector::inject() {
return false;
bool Changed = false;
for (auto &BB : F) {
- if (AnnotateSelect) {
- for (auto &I : BB) {
- if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof))
- setBranchWeights(I, {SelectTrueWeight, SelectFalseWeight},
- /*IsExpected=*/false);
- }
+ for (auto &I : BB) {
+ if (AnnotateSelect && isa<SelectInst>(I) &&
+ !I.getMetadata(LLVMContext::MD_prof))
----------------
mingmingl-llvm wrote:
nit: for reader's context, add a comment to explain how/when `I.getMetadata(LLVMContext::MD_prof)` is true (i.e., profile metadata already exists) and this set-metadata code path runs again on the same instruction, and why avoid setting it again (e.g. is setting `!prof` metadata idempotent, or if it's not necessarily idempotent, explain a little bit about why we prefer the first one)
https://github.com/llvm/llvm-project/pull/154657
More information about the llvm-commits
mailing list