[all-commits] [llvm/llvm-project] e517cf: [InstrPGO] Support cold function coverage instrume...
Lei Wang via All-commits
all-commits at lists.llvm.org
Mon Oct 28 10:14:06 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e517cfc531886bf6ed64b4e7109bb3141ac7f430
https://github.com/llvm/llvm-project/commit/e517cfc531886bf6ed64b4e7109bb3141ac7f430
Author: Lei Wang <wlei at fb.com>
Date: 2024-10-28 (Mon, 28 Oct 2024)
Changed paths:
M clang/include/clang/Driver/Options.td
M clang/lib/Driver/ToolChain.cpp
M clang/lib/Driver/ToolChains/Clang.cpp
A clang/test/CodeGen/pgo-cold-function-coverage.c
A clang/test/Driver/fprofile-generate-cold-function-coverage.c
M llvm/lib/Passes/PassBuilderPipelines.cpp
M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
A llvm/test/Transforms/PGOProfile/instr-gen-cold-function.ll
Log Message:
-----------
[InstrPGO] Support cold function coverage instrumentation (#109837)
This patch adds support for cold function coverage instrumentation based
on sampling PGO counts. The major motivation is to detect dead functions
for the services that are optimized with sampling PGO. If a function is
covered by sampling profile count (e.g., those with an entry count > 0),
we choose to skip instrumenting those functions, which significantly
reduces the instrumentation overhead.
More details about the implementation and flags:
- Added a flag `--pgo-instrument-cold-function-only` in
`PGOInstrumentation.cpp` as the main switch to control skipping the
instrumentation.
- Built the extra instrumentation passes(a bundle of passes in
`addPGOInstrPasses`) under sampling PGO pipeline. This is controlled by
`--instrument-cold-function-only-path` flag.
- Added a driver flag `-fprofile-generate-cold-function-coverage`:
- 1) Config the flags in one place, i,e. adding
`--instrument-cold-function-only-path=<...>` and
`--pgo-function-entry-coverage`. Note that the instrumentation file path
is passed through `--instrument-sample-cold-function-path`, because we
cannot use the `PGOOptions.ProfileFile` as it's already used by
`-fprofile-sample-use=<...>`.
- 2) makes linker to link `compiler_rt.profile` lib(see
[ToolChain.cpp#L1125-L1131](https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChain.cpp#L1125-L1131)
).
- Added a flag(`--pgo-cold-instrument-entry-threshold`) to config entry
count to determine cold function.
Overall, the full command is like:
```
clang++ -O2 -fprofile-generate-cold-function-coverage=<...> -fprofile-sample-use=<...> code.cc -o code
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list