https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71046
Bug ID: 71046 Summary: gcov time hog Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- struct A { char a1, a2, a3, a4, a5, a6, a7, a8, a9; char b1, b2, b3, b4, b5, b6, b7, b8, b9; char c1, c2, c3, c4, c5; }; struct A s; int main () { if (__builtin_expect (s.a1 < 0 || s.a1 > 200 || s.a2 < 0 || s.a2 > 200 || s.a3 < 0 || s.a3 > 200 || s.a4 < 0 || s.a4 > 200 || s.a5 < 0 || s.a5 > 200 || s.a6 < 0 || s.a6 > 200 || s.a7 < 0 || s.a7 > 200 || s.a8 < 0 || s.a8 > 200 || s.a9 < 0 || s.a9 > 200 || s.b1 < 0 || s.b1 > 200 || s.b2 < 0 || s.b2 > 200 || s.b3 < 0 || s.b3 > 200 || s.b4 < 0 || s.b4 > 200 || s.b5 < 0 || s.b5 > 200 || s.b6 < 0 || s.b6 > 200 || s.b7 < 0 || s.b7 > 200 || s.b8 < 0 || s.b8 > 200 || s.b9 < 0 || s.b9 > 200 || s.c1 < 0 || s.c1 > 200 || s.c2 < 0 || s.c2 > 200 || s.c3 < 0 || s.c3 > 200 || s.c4 < 0 || s.c4 > 200 || s.c5 < 0 || s.c5 > 200, 0)) __builtin_printf ("hello\n"); return 0; } (reduced from Linux kernel) with gcc -O2 -fprofile-arcs -ftest-coverage test.c ./a.out gcov -b -c -d -a test.gcda gets stuck in accumulate_line_counts until killed. There are no loops in the testcase, all bbs have at most 2 successors, one bb has 23 predecessors, most others have just one. The comment in accumulate_line_counts says: /* Find the loops. This uses the algorithm described in Tiernan 'An Efficient Search Algorithm to Find the Elementary Circuits of a Graph', CACM Dec 1970. We hold the P array by having each block point to the arc that connects to the previous block. The H array is implicitly held because of the arc ordering, and the block's previous arc pointer. Although the algorithm is O(N^3) for highly connected graphs, at worst we'll have O(N^2), as most blocks have only one or two exits. Most graphs will be small. For each loop we find, locate the arc with the smallest transition count, and add that to the cumulative count. Decrease flow over the cycle and remove the arc from consideration. */