[llvm-cov gcov] Compute unmeasured arc counts by Kirchhoff's circuit law
authorFangrui Song <i@maskray.me>
Wed, 9 Sep 2020 01:45:11 +0000 (18:45 -0700)
committerFangrui Song <i@maskray.me>
Wed, 9 Sep 2020 01:45:11 +0000 (18:45 -0700)
commitb9d086693b5baebc477793af0d86a447bae01b6f
tree524191052ac72b87814db4b1f474b94f773aedbd
parent88b368a1c47bca536f03041f7464235b94ea98a1
[llvm-cov gcov] Compute unmeasured arc counts by Kirchhoff's circuit law

For a CFG G=(V,E), Knuth describes that by Kirchoff's circuit law, the minimum
number of counters necessary is |E|-(|V|-1). The emitted edges form a spanning
tree. libgcov emitted .gcda files leverages this optimization while clang
--coverage's doesn't.

Propagate counts by Kirchhoff's circuit law so that llvm-cov gcov can
correctly print line counts of gcc --coverage emitted files and enable
the future improvement of clang --coverage.
compiler-rt/test/profile/Inputs/instrprof-gcov-multiple-bbs-single-line.c.gcov
llvm/include/llvm/ProfileData/GCOV.h
llvm/lib/ProfileData/GCOV.cpp
llvm/test/tools/llvm-cov/gcov-4.7.c
llvm/test/tools/llvm-cov/gcov-8.c
llvm/test/tools/llvm-cov/gcov-9.c