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

Xiangyang Guo via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 13:17:43 PDT 2024


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

Currently `Candidate.SizeCost < SampleThreshold` is used to make inline decision. `SampleThreshold` could be zero, which makes candidates with zero SizeCost not inlined. This change always inlines candidates with zero SizeCost. 

Internal workloads show neutral or tiny (<0.2%) perf win. Preinliner shows ~4% more inlining. 

>From de2e88d2795091c01f997e55467e98015ec11072 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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp
index 87df6996aa435a..87f951459a1053 100644
--- a/llvm/tools/llvm-profgen/CSPreInliner.cpp
+++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp
@@ -152,6 +152,9 @@ uint32_t CSPreInliner::getFuncSize(const ContextTrieNode *ContextNode) {
 }
 
 bool CSPreInliner::shouldInline(ProfiledInlineCandidate &Candidate) {
+  if (Candidate.SizeCost == 0)
+    return true;
+
   bool WasInlined =
       Candidate.CalleeSamples->getContext().hasAttribute(ContextWasInlined);
   // If replay inline is requested, simply follow the inline decision of the



More information about the llvm-commits mailing list