[PATCH] D138231: [CSSPGO][Preinliner] Use one for zero-sized functions when computing inline budge

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 17 11:50:16 PST 2022


hoy created this revision.
Herald added subscribers: modimo, wenlei.
Herald added a project: All.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Use one to avoid multiplication with a zero func size which otherwise would result in no inlining. This could happen when all of the original function's code is gone and only inlined code is left.

Testing on one internal benchmark shows neutral perf impact, but dynamic instruction count reduces by 0.5%. Also there are visible differences in generated profile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138231

Files:
  llvm/tools/llvm-profgen/CSPreInliner.cpp


Index: llvm/tools/llvm-profgen/CSPreInliner.cpp
===================================================================
--- llvm/tools/llvm-profgen/CSPreInliner.cpp
+++ llvm/tools/llvm-profgen/CSPreInliner.cpp
@@ -190,7 +190,11 @@
   unsigned FuncSize =
       getFuncSize(ContextTracker.getContextNodeForProfile(FSamples));
   unsigned FuncFinalSize = FuncSize;
-  unsigned SizeLimit = FuncSize * ProfileInlineGrowthLimit;
+  // Use one to avoid multiplication with a zero func size. This could happen
+  // when all of the original function's code is gone and only inlined code is
+  // left.
+  unsigned ModifiedFuncSize = FuncSize ? FuncSize : 1;
+  unsigned SizeLimit = ModifiedFuncSize * ProfileInlineGrowthLimit;
   SizeLimit = std::min(SizeLimit, (unsigned)ProfileInlineLimitMax);
   SizeLimit = std::max(SizeLimit, (unsigned)ProfileInlineLimitMin);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138231.476200.patch
Type: text/x-patch
Size: 856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221117/e4e4e02e/attachment.bin>


More information about the llvm-commits mailing list