This is an extended set of patches with both review feedback from the v4 set, as well as a few serious bug fixes and improvements, plus test cases.
There has only been a small-ish adjustment to the algorithm itself, in expression isolation step. Because of gotos this might need to run multiple times if it is detected that the expression subgraph has more than two neighbors (in which case it *must* be more than a single Boolean expression). This fixes some problems that mostly happen under optimization, but it also helps correctness by having extra checks that what we found satisifies some fundamental properties. Most other bugs were implementation errors. I have broken the work up into smaller pieces that fix a single issue each, including addressing review feedback. I hope this will make the patch set easier to review and check how comments are addressed, but it also means that most of the patch set does not have a the proper commit format etc. I plan to squash most, if not all, of the commits before merge where this will be addressed. In September I proposed [1] an idea on how to fix the if (a) if (b) {} counted as if (a && b) problem. If such a fix should be implemented no real changes will have to happen to the tree profiling, the only change necessary to the tree profiling is updating the test to reflect the counting. To test the compiler I have built all dependencies (libraries, programs) to build git, systemd, and openjdk, which includes llvm, perl, python, openssl, icu, valgrind, and elfutils. This list is non-exhaustive. All these programs now *build* with coverage enabled without failing (hitting an assert), but I have not verified counting for these programs. [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631254.html --- gcc/builtins.cc | 2 +- gcc/collect2.cc | 7 +- gcc/common.opt | 9 + gcc/doc/gcov.texi | 38 + gcc/doc/invoke.texi | 21 + gcc/gcc.cc | 4 +- gcc/gcov-counter.def | 3 + gcc/gcov-dump.cc | 24 + gcc/gcov-io.h | 3 + gcc/gcov.cc | 209 ++++- gcc/ipa-inline.cc | 2 +- gcc/ipa-split.cc | 3 +- gcc/passes.cc | 3 +- gcc/profile.cc | 92 +- gcc/testsuite/g++.dg/gcov/gcov-18.C | 246 ++++++ gcc/testsuite/gcc.misc-tests/gcov-19.c | 1471 ++++++++++++++++++++++++++++++++ gcc/testsuite/gcc.misc-tests/gcov-20.c | 22 + gcc/testsuite/gcc.misc-tests/gcov-21.c | 16 + gcc/testsuite/gcc.misc-tests/gcov-22.c | 71 ++ gcc/testsuite/gcc.misc-tests/gcov-23.c | 149 ++++ gcc/testsuite/lib/gcov.exp | 191 ++++- gcc/tree-profile.cc | 1123 +++++++++++++++++++++++- libgcc/libgcov-merge.c | 5 + 23 files changed, 3688 insertions(+), 26 deletions(-)