[PATCH] D108180: [CSSPGO] Track and use context-sensitive post-optimization function size to drive global pre-inliner in llvm-profgen

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 18:46:59 PDT 2021


wenlei created this revision.
wenlei added reviewers: wmi, hoy, wlei, davidxl.
Herald added subscribers: ormris, modimo, lxfind, hiraditya, eraman.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This change enables llvm-profgen to use accurate context-sensitive post-optimization function byte size as a cost proxy to drive global preinline decisions.

To do this, BinarySizeContextTracker is introduced to track function byte size under different inline context during disassembling. In preinliner, we can not query context byte size under switch `context-cost-for-preinliner`. The tracker uses a reverse trie to keep size of functions under different context (callee as parent, caller as child), and it can give best/longest possible matching context size for given input context.

The new size cost is off by default. There're a few TODOs that needs to addressed: 1) avoid dangling string from `Offset2LocStackMap`, which will be addressed in split context work; 2) using inlinee's entry probe to make sure we have correct zero size for inlinee that's completely optimized away after inlining. Some tuning is also needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108180

Files:
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
  llvm/lib/Transforms/IPO/SampleContextTracker.cpp
  llvm/test/tools/llvm-profgen/Inputs/cs-preinline-cost.perfbin
  llvm/test/tools/llvm-profgen/Inputs/cs-preinline-cost.perfscript
  llvm/test/tools/llvm-profgen/cs-preinline-cost.test
  llvm/tools/llvm-profgen/CSPreInliner.cpp
  llvm/tools/llvm-profgen/CSPreInliner.h
  llvm/tools/llvm-profgen/ProfileGenerator.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108180.366786.patch
Type: text/x-patch
Size: 26245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210817/87dc0adb/attachment.bin>


More information about the llvm-commits mailing list