[PATCH] D116180: [InstrProf] Add single byte coverage mode

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 22 11:31:13 PST 2021


ellis created this revision.
Herald added subscribers: dexonsmith, wenlei, jdoerfert, hiraditya.
ellis added reviewers: kyulee, MaskRay.
ellis published this revision for review.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

Use the llvm flag `-pgo-coverage-instrumentation` to create single byte "counters" to track functions coverage. This mode has significatly 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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116180

Files:
  compiler-rt/include/profile/InstrProfData.inc
  compiler-rt/lib/profile/InstrProfiling.c
  compiler-rt/lib/profile/InstrProfilingMerge.c
  compiler-rt/test/profile/instrprof-coverage.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/ProfileData/InstrProfWriter.h
  llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/InstrProfWriter.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Instrumentation/InstrProfiling/coverage.ll
  llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll
  llvm/test/Transforms/PGOProfile/coverage.ll
  llvm/tools/llvm-profdata/llvm-profdata.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116180.395910.patch
Type: text/x-patch
Size: 42941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211222/77dc4a61/attachment.bin>


More information about the llvm-commits mailing list