[clang] [llvm] [llvm][misexpect] Update MisExpect to use provenance tracking metadata (PR #86610)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 10:25:59 PDT 2024


================
@@ -151,15 +151,9 @@ void verifyMisExpect(Instruction &I, ArrayRef<uint32_t> RealWeights,
   uint64_t TotalBranchWeight =
       LikelyBranchWeight + (UnlikelyBranchWeight * NumUnlikelyTargets);
 
-  // FIXME: When we've addressed sample profiling, restore the assertion
-  //
-  // We cannot calculate branch probability if either of these invariants aren't
-  // met. However, MisExpect diagnostics should not prevent code from compiling,
-  // so we simply forgo emitting diagnostics here, and return early.
-  // assert((TotalBranchWeight >= LikelyBranchWeight) && (TotalBranchWeight > 0)
-  //              && "TotalBranchWeight is less than the Likely branch weight");
-  if ((TotalBranchWeight == 0) || (TotalBranchWeight <= LikelyBranchWeight))
-    return;
+  // Failing this assert means that we have corrupted metadata.
+  assert((TotalBranchWeight >= LikelyBranchWeight) && (TotalBranchWeight > 0) &&
----------------
ilovepi wrote:

it was introduced after we found an issue w/ thinLTO, since sample profiling can run multiple times. We then introduced an early return to avoid division by zero, but now it should be safe to just use the assert, since we should only ever process branches w/ the provenance tag.

for now, I guess let's leave it as an assert, since I don't expect it to fire, and users don't have control of it.

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


More information about the llvm-commits mailing list