[PATCH] D98590: [CSSPGO] Load context profile for external functions in PreLink and populate ThinLTO import list

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 13 14:17:51 PST 2021


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

For ThinLTO's prelink compilation, we need to put external inline candidates into an import list attached to function's entry count metadata. This enables ThinLink to treat such cross module callee as hot in summary index, and later helps postlink to import them for profile guided cross module inlining.

For AutoFDO, the import list is retrieved by traversing the nested inlinee functions. For CSSPGO, since profile is flatterned, a few things need to happen for it to work:

- When loading input profile in extended binary format, we need to load all child context profile whose parent is in current module, so context trie for current module includes potential cross module inlinee.
- In order to make the above happen, we need to know whether input profile is CSSPGO profile before start reading function profile, hence a flag for profile summary section is added.
- When searching for cross module inline candidate, we need to walk through the context trie instead of nested inlinee profile (callsite sample of AutoFDO profile).
- Now that we have more accurate counts with CSSPGO, we swtiched to use entry count instead of total count to decided if an external callee is potentially beneficial to inline. This make it consistent with how we determine whether call tagert is potential inline candidate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98590

Files:
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/test/Transforms/SampleProfile/Inputs/csspgo-import-list.prof
  llvm/test/Transforms/SampleProfile/csspgo-import-list.ll
  llvm/tools/llvm-profgen/ProfileGenerator.cpp
  llvm/tools/llvm-profgen/ProfileGenerator.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98590.330475.patch
Type: text/x-patch
Size: 21542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210313/8591c10b/attachment.bin>


More information about the llvm-commits mailing list