[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:40 PDT 2024


================
@@ -5196,7 +5198,11 @@ void SwitchInstProfUpdateWrapper::init() {
   if (!ProfileData)
     return;
 
-  if (ProfileData->getNumOperands() != SI.getNumSuccessors() + 1) {
+  // FIXME: This check belongs in ProfDataUtils. Its almost equivalent to
+  // getValidBranchWeightMDNode(), but the need to use llvm_unreachable
+  // makes them slightly different.
+  if (ProfileData->getNumOperands() !=
+      SI.getNumSuccessors() + getBranchWeightOffset(ProfileData)) {
----------------
MatzeB wrote:

This seems simple enough to do something about it? Could for example add a `getNumBranchWeights(<profile_data>)` API so this can become `getNumBranchWeights(ProfileData) != SI.getNumSuccessors()`?

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


More information about the llvm-branch-commits mailing list