[gcov] Add spanning tree optimization
authorFangrui Song <i@maskray.me>
Sun, 13 Sep 2020 07:07:31 +0000 (00:07 -0700)
committerFangrui Song <i@maskray.me>
Sun, 13 Sep 2020 07:07:31 +0000 (00:07 -0700)
commit63182c2ac0b643a60d397274e8a31166fc7243fa
tree9e7fda1afadbb8658d9df7f0bea5a6d79ca66ec1
parentf086e85eea94a51eb42115496ac5d24f07bc8791
[gcov] Add spanning tree optimization

gcov is an "Edge Profiling with Edge Counters" application according to
Optimally Profiling and Tracing Programs (1994).

The minimum number of counters necessary is |E|-(|V|-1). The unmeasured edges
form a spanning tree. Both GCC --coverage and clang -fprofile-generate leverage
this optimization. This patch implements the optimization for clang --coverage.
The produced .gcda files are much smaller now.
clang/test/CodeGen/code-coverage-tsan.c
compiler-rt/test/profile/Posix/gcov-fork.c
compiler-rt/test/profile/gcov-dump-and-remove.c
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/test/Transforms/GCOVProfiling/atomic-counter.ll
llvm/test/Transforms/GCOVProfiling/split-indirectbr-critical-edges.ll [new file with mode: 0644]