================
@@ -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;
----------------
shawbyoung wrote:

I’m leaning towards the block count heuristic now. I think the 1M and 4x1K exec 
count block case is likely pretty common – I imagine functions with loops would 
look a lot like this. Having some blocks matched exactly would suggest to me 
that there would likely be a reasonable amount of similarity between the 
profiled function and existing function relationally, which block coldness 
likely doesn’t have an outsized bearing on. I think having a reasonably high 
threshold for matched blocks would conservatively allow us to drop functions in 
high discrepancy – I’ll test this on a production binary. 

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