Use the llvm flag `-pgo-function-entry-coverage` to create single byte "counters" to track functions coverage. This mode has significantly less size overhead in both code and data because * We mark a function as "covered" with a store instead of an increment which generally requires fewer assembly instructions * We use a single byte per function rather than 8 bytes per block The trade off of course is that this mode only tells you if a function has been covered. This is useful, for example, to detect dead code. When combined with debug info correlation [0] we are able to create an instrumented Clang binary that is only 150M (the vanilla Clang binary is 143M). That is an overhead of 7M (4.9%) compared to the default instrumentation (without value profiling) which has an overhead of 31M (21.7%). [0] https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4 Reviewed By: kyulee Differential Revision: https://reviews.llvm.org/D116180
27 lines
1.8 KiB
C
27 lines
1.8 KiB
C
// Value profiling is currently not supported in lightweight mode.
|
|
// RUN: %clang_pgogen -o %t.normal -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
|
|
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal
|
|
// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw
|
|
|
|
// RUN: %clang_pgogen -o %t.d4 -g -gdwarf-4 -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
|
|
// RUN: env LLVM_PROFILE_FILE=%t.d4.proflite %run %t.d4
|
|
// RUN: llvm-profdata merge -o %t.d4.profdata --debug-info=%t.d4 %t.d4.proflite
|
|
|
|
// RUN: diff %t.normal.profdata %t.d4.profdata
|
|
|
|
// RUN: %clang_pgogen -o %t -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
|
|
// RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t
|
|
// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite
|
|
|
|
// RUN: diff %t.normal.profdata %t.profdata
|
|
|
|
// RUN: %clang_pgogen -o %t.cov -g -mllvm --debug-info-correlate -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
|
|
// RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov
|
|
// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.cov.proflite
|
|
|
|
// RUN: %clang_pgogen -o %t.cov.normal -mllvm --pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp
|
|
// RUN: env LLVM_PROFILE_FILE=%t.cov.profraw %run %t.cov.normal
|
|
// RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
|
|
|
|
// RUN: diff %t.cov.normal.profdata %t.cov.profdata
|