[llvm-branch-commits] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)
David Li via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 5 21:20:42 PDT 2024
================
@@ -123,6 +121,25 @@ bool hasValidBranchWeightMD(const Instruction &I) {
return getValidBranchWeightMDNode(I);
}
+bool hasBranchWeightProvenance(const Instruction &I) {
+ auto *ProfileData = I.getMetadata(LLVMContext::MD_prof);
+ return hasBranchWeightProvenance(ProfileData);
+}
+
+bool hasBranchWeightProvenance(const MDNode *ProfileData) {
+ if (!isBranchWeightMD(ProfileData))
+ return false;
+ auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(1));
+ // NOTE: if we ever have more types of branch weight provenance,
+ // we need to check the string value is "expected". For now, we
+ // supply a more generic API, and avoid the spurious comparisons.
+ return ProfDataName;
----------------
david-xl wrote:
add a debug assert for now?
https://github.com/llvm/llvm-project/pull/86609
More information about the llvm-branch-commits
mailing list