[all-commits] [llvm/llvm-project] ac068e: [CSSPGO] Consume pseudo-probe-based AutoFDO profile

Hongtao Yu via All-commits all-commits at lists.llvm.org
Wed Dec 16 16:06:54 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: ac068e014b22548ae1c0dc5ff3dd8821d41f45c0
      https://github.com/llvm/llvm-project/commit/ac068e014b22548ae1c0dc5ff3dd8821d41f45c0
  Author: Hongtao Yu <hoy at fb.com>
  Date:   2020-12-16 (Wed, 16 Dec 2020)

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

  Log Message:
  -----------
  [CSSPGO] Consume pseudo-probe-based AutoFDO profile

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.

Differential Revision: https://reviews.llvm.org/D92347




More information about the All-commits mailing list