[llvm-branch-commits] [llvm][IR] Extend BranchWeightMetadata to track provenance of weights (PR #86609)

Matthias Braun via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Apr 8 18:28:42 PDT 2024


================
@@ -4756,8 +4757,10 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) {
 
   // Check consistency of !prof branch_weights metadata.
   if (ProfName.equals("branch_weights")) {
+    unsigned int Offset = getBranchWeightOffset(I);
     if (isa<InvokeInst>(&I)) {
-      Check(MD->getNumOperands() == 2 || MD->getNumOperands() == 3,
+      Check(MD->getNumOperands() == (1 + Offset) ||
+                MD->getNumOperands() == (2 + Offset),
----------------
MatzeB wrote:

More opportunities for a possible `getNumBranchWeights(...)` API...

https://github.com/llvm/llvm-project/pull/86609


More information about the llvm-branch-commits mailing list