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

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 13:18:14 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Xiangyang (Mark) Guo (helloguo)

<details>
<summary>Changes</summary>

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. 

---
Full diff: https://github.com/llvm/llvm-project/pull/88785.diff


1 Files Affected:

- (modified) llvm/tools/llvm-profgen/CSPreInliner.cpp (+3) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list