[all-commits] [llvm/llvm-project] 11d307: [InstrProf] Add single byte coverage mode

Ellis Hoag via All-commits all-commits at lists.llvm.org
Thu Jan 27 17:39:19 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 11d3074267324e811ade248a991564fa6722754e
      https://github.com/llvm/llvm-project/commit/11d3074267324e811ade248a991564fa6722754e
  Author: Ellis Hoag <ellis.sparky.hoag at gmail.com>
  Date:   2022-01-27 (Thu, 27 Jan 2022)

  Changed paths:
    M compiler-rt/include/profile/InstrProfData.inc
    M compiler-rt/lib/profile/InstrProfiling.c
    M compiler-rt/lib/profile/InstrProfilingBuffer.c
    M compiler-rt/lib/profile/InstrProfilingMerge.c
    M compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
    M compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-bar.h
    M compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-foo.cpp
    M compiler-rt/test/profile/Inputs/instrprof-debug-info-correlate-main.cpp
    M compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
    A compiler-rt/test/profile/instrprof-coverage.c
    A compiler-rt/test/profile/instrprof-merge-entry-cover.c
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/IR/IntrinsicInst.h
    M llvm/include/llvm/IR/Intrinsics.td
    M llvm/include/llvm/ProfileData/InstrProf.h
    M llvm/include/llvm/ProfileData/InstrProfData.inc
    M llvm/include/llvm/ProfileData/InstrProfReader.h
    M llvm/include/llvm/ProfileData/InstrProfWriter.h
    M llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/ProfileData/InstrProf.cpp
    M llvm/lib/ProfileData/InstrProfReader.cpp
    M llvm/lib/ProfileData/InstrProfWriter.cpp
    M llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    A llvm/test/Instrumentation/InstrProfiling/coverage.ll
    A llvm/test/Instrumentation/InstrProfiling/debug-info-correlate-coverage.ll
    A llvm/test/Transforms/PGOProfile/coverage.ll
    A llvm/test/tools/llvm-profdata/Inputs/function-entry-coverage.profdata
    A llvm/test/tools/llvm-profdata/show-covered.test
    M llvm/tools/llvm-profdata/llvm-profdata.cpp

  Log Message:
  -----------
  [InstrProf] Add single byte coverage mode

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




More information about the All-commits mailing list