[PATCH] D124490: [InstrProf] Minimal Block Coverage

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 11:19:34 PDT 2022


ellis created this revision.
Herald added subscribers: wenlei, hiraditya, mgorny.
Herald added a project: All.
ellis edited the summary of this revision.
ellis edited the summary of this revision.
ellis added reviewers: phosek, spupyrev, kyulee, wenlei, davidxl.
ellis published this revision for review.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

This diff implements minimal block coverage instrumentation. When the `-pgo-block-coverage` option is used, basic blocks will be instrumented for block coverage using single byte booleans. The coverage of some basic blocks can be inferred from others, so not every basic block is instrumented. In fact, we found that only ~60% of basic blocks need to be instrumented. These differences lead to less size overhead when compared to instrumenting block counts. For example, block coverage on the clang binary has an overhead of 20 Mi (17%) compared to 56 Mi (47%) with block counts.

Special thanks to Julian Mestre for creating this block coverage inference algorithm.

1. Binary size of `clang` using `-O2`
2. Base
  - `.text`: 65.8 Mi
  - Total: 119 Mi
3. IRPGO (`-fprofile-generate -mllvm -disable-vp -mllvm -debug-info-correlate`)
  - `.text`: 93.0 Mi
  - `__llvm_prf_cnts`: 14.5 Mi
  - Total: 175 Mi
4. Minimal Block Coverage (`-fprofile-generate -mllvm -disable-vp -mllvm -debug-info-correlate -mllvm -pgo-block-coverage`)
  - `.text`: 82.1 Mi
  - `__llvm_prf_cnts`: 1.38 Mi
  - Total: 139 Mi


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124490

Files:
  compiler-rt/test/profile/instrprof-coverage.c
  compiler-rt/test/profile/instrprof-entry-coverage.c
  llvm/include/llvm/Analysis/BlockFrequencyInfo.h
  llvm/include/llvm/Transforms/Instrumentation/BlockCoverageInference.h
  llvm/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/Transforms/Instrumentation/BlockCoverageInference.cpp
  llvm/lib/Transforms/Instrumentation/CMakeLists.txt
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/CodeGen/AArch64/machine-outliner-profile.ll
  llvm/test/Transforms/PGOProfile/coverage.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124490.425350.patch
Type: text/x-patch
Size: 45712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/36087702/attachment.bin>


More information about the llvm-commits mailing list