[PATCH] D92347: [CSSPGO] Consume pseudo-probe-based AutoFDO profile

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 14:02:26 PST 2020


hoy created this revision.
Herald added subscribers: llvm-commits, dexonsmith, wenlei, hiraditya, mgorny.
Herald added a project: LLVM.
hoy requested review of this revision.

This change enables pseudo-probe-based sample counts to be consumed by the sample profile loader under the regular -fprofile-sample-use switch with minimal adjustments to the existing sample file formats. After the counts are imported, a probe helper, aka, a PseudoProbeManager object, is automatically launched to verify the CFG checksum of every function in the current compilation against the corresponding checksum from the profile. Mismatched checksums will cause a function profile to be slipped. A SampleProfileProber pass is scheduled before any of the SampleProfileLoader instances so that the CFG checksums as well as probe mappings are available during the profile loading time. The PseudoProbeManager object is set up right after the profile reading is done. In the future a CFG-based fuzzy matching could be done in PseudoProbeManager.

Samples will be applied only to pseudo probe instructions as well as probed callsites once the checksum verification goes through. Those instructions are processed in the same way that regular instructions would be processed in the line-number-based scenario. In other words, a function is processed in a regular way as if it was reduced to just containing pseudo probes (block probes and callsites).

Adjustment to profile format

A CFG checksum field is being added to the existing AutoFDO profile formats. So far only the text format and the extended binary format are supported. For the text format, a new line like

  !CFGChecksum: 12345
    
    is added to the end of the body sample lines. For the extended binary profile format, we introduce a metadata section to store the checksum map from function names to their CFG checksums.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92347

Files:
  llvm/include/llvm/IR/PseudoProbe.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/ProfileData/SampleProfReader.h
  llvm/include/llvm/ProfileData/SampleProfWriter.h
  llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/PseudoProbe.cpp
  llvm/lib/ProfileData/SampleProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/test/Transforms/SampleProfile/Inputs/pseudo-probe-profile.prof
  llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll
  llvm/test/tools/llvm-profdata/Inputs/pseudo-probe-profile.proftext
  llvm/test/tools/llvm-profdata/merge-probe-profile.test
  llvm/tools/llvm-profdata/llvm-profdata.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92347.308475.patch
Type: text/x-patch
Size: 44010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201130/4eba9778/attachment.bin>


More information about the llvm-commits mailing list