================
@@ -592,10 +599,15 @@ void preprocessUnreachableBlocks(FlowFunction &Func) {
 /// Decide if stale profile matching can be applied for a given function.
 /// Currently we skip inference for (very) large instances and for instances
 /// having "unexpected" control flow (e.g., having no sink basic blocks).
-bool canApplyInference(const FlowFunction &Func) {
+bool canApplyInference(const FlowFunction &Func,
+                       const yaml::bolt::BinaryFunctionProfile &YamlBF) {
   if (Func.Blocks.size() > opts::StaleMatchingMaxFuncSize)
     return false;
 
+  if ((double)Func.MatchedExecCount / YamlBF.ExecCount >=
+      opts::MatchedProfileThreshold / 100.0)
+    return false;
----------------
aaupov wrote:

It's a tricky question how to define the cutoff in terms of sufficient matching.
I first thought of defining a block count based cutoff (if we matched >5% of 
blocks, proceed with matching), but then what if these are cold blocks covering 
<1% of exec count? In this case we'd end up guessing/propagating most samples.

For block-based matching, the threshold should be higher than 5%, perhaps 
closer to a half? For exec count based matching, I'd feel comfortable with 5% 
as threshold.

https://github.com/llvm/llvm-project/pull/95156
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to