Bug 71046 - gcov time hog
Summary: gcov time hog
Status: RESOLVED DUPLICATE of bug 67992
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-10 12:17 UTC by Jakub Jelinek
Modified: 2016-05-10 12:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2016-05-10 12:17:48 UTC
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.  */
Comment 1 Jakub Jelinek 2016-05-10 12:24:36 UTC
Oops, sorry, this is already filed.

*** This bug has been marked as a duplicate of bug 67992 ***