[llvm] [Preinliner] Always inline when SizeCost is zero (PR #88785)

Xiangyang Guo via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 16:36:35 PDT 2024


https://github.com/helloguo updated https://github.com/llvm/llvm-project/pull/88785

>From f001afdb099be9cb8b7929d2ab0124d9532bfca5 Mon Sep 17 00:00:00 2001
From: helloguo <helloguo at meta.com>
Date: Mon, 15 Apr 2024 11:55:10 -0700
Subject: [PATCH] [Preinliner] Always inline when SizeCost is zero

---
 llvm/tools/llvm-profgen/CSPreInliner.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp
index 87df6996aa435a..4788e94aa9a3f9 100644
--- a/llvm/tools/llvm-profgen/CSPreInliner.cpp
+++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp
@@ -179,11 +179,8 @@ bool CSPreInliner::shouldInline(ProfiledInlineCandidate &Candidate) {
         (NormalizationUpperBound - NormalizationLowerBound);
     if (NormalizedHotness > 1.0)
       NormalizedHotness = 1.0;
-    // Add 1 to ensure hot callsites get a non-zero threshold, which could
-    // happen when SampleColdCallSiteThreshold is 0. This is when we do not
-    // want any inlining for cold callsites.
     SampleThreshold = SampleHotCallSiteThreshold * NormalizedHotness * 100 +
-                      SampleColdCallSiteThreshold + 1;
+                      SampleColdCallSiteThreshold;
     // Bump up the threshold to favor previous compiler inline decision. The
     // compiler has more insight and knowledge about functions based on their IR
     // and attribures and should be able to make a more reasonable inline
@@ -192,7 +189,7 @@ bool CSPreInliner::shouldInline(ProfiledInlineCandidate &Candidate) {
       SampleThreshold *= CSPreinlMultiplierForPrevInl;
   }
 
-  return (Candidate.SizeCost < SampleThreshold);
+  return (Candidate.SizeCost <= SampleThreshold);
 }
 
 void CSPreInliner::processFunction(const FunctionId Name) {



More information about the llvm-commits mailing list