[llvm] [Sample Profile] Check hot callsite threshold when inlining a function with a sample profile (PR #93286)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 08:44:27 PDT 2024


================
@@ -1391,10 +1391,12 @@ SampleProfileLoader::shouldInlineCandidate(InlineCandidate &Candidate) {
       return InlineCost::getAlways("preinliner");
   }
 
-  // For old FDO inliner, we inline the call site as long as cost is not
-  // "Never". The cost-benefit check is done earlier.
+  // For old FDO inliner, we inline the call site if it is below hot threshold,
+  // even if the function is hot based on sample profile data. This is to
+  // prevent huge functions from being inlined.
   if (!CallsitePrioritizedInline) {
-    return InlineCost::get(Cost.getCost(), INT_MAX);
+    return InlineCost::get(Cost.getCost(),
+                           Params.HotCallSiteThreshold.value_or(INT_MAX));
----------------
WenleiHe wrote:

Should we use `SampleThreshold` here? and then simply make it unconditional, i.e. merge with line 1404.

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


More information about the llvm-commits mailing list