https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108658

--- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> -fno-move-loop-stores disables the store motion.

Ok, so I can confirm both -fno-move-loop-stores or -fprofile-update=atomic lead
to properly collected numbers with -O2:

$ rm *gcda ; gcc pr108658.c -O2 idle.c --coverage -fprofile-update=atomic &&
./a.out && gcov-dump -l a-idle.gcda
a-idle.gcda:data:magic `gcda':version `B30 '
a-idle.gcda:stamp 900763911
a-idle.gcda:checksum 3617524158
a-idle.gcda:  a1000000:   8:OBJECT_SUMMARY runs=1, sum_max=711808344
a-idle.gcda:  01000000:  12:FUNCTION ident=2013603264,
lineno_checksum=0x5f7f7dbf, cfg_checksum=0xc48fabfe
a-idle.gcda:    01a10000:   8:COUNTERS arcs 1 counts
a-idle.gcda:                   0: 711842716 

However, we still end up with zero execution number of the problematic line:

gcov -t a-idle.gcda
        -:    0:Source:idle.c
        -:    0:Graph:a-idle.gcno
        -:    0:Data:a-idle.gcda
        -:    0:Runs:1
    #####:    1:void *idle(void *ignored)
        -:    2:{
        -:    3:  while (1) {
        -:    4:    /* Do nothing */
        -:    5:  }
        -:    6:
        -:    7:  return 0;
        -:    8:}

That's caused by many empty blocks at the time of the creation of the note
file:

(gdb) pcfun
void * idle (void * ignored)
{
  <bb 2> [local count: 10631108]:

  <bb 3> [local count: 1073741824]:

  <bb 4> [local count: 1073741824]:
  goto <bb 3>; [100.00%]

}

$ gcov-dump -l a-idle.gcno
a-idle.gcno:note:magic `gcno':version `B30 '
a-idle.gcno:stamp 900904516
a-idle.gcno:checksum 0
a-idle.gcno:cwd: /home/marxin/Programming/testcases
a-idle.gcno:  01000000:  52:FUNCTION ident=2013603264,
lineno_checksum=0x5f7f7dbf, cfg_checksum=0xc48fabfe, `idle' idle.c:1:7-8:1
a-idle.gcno:    01410000:   4:BLOCKS 5 blocks
a-idle.gcno:    01430000:  12:ARCS 1 arcs
a-idle.gcno:                  block 0: 2:0005(tree,fall)
a-idle.gcno:    01430000:  12:ARCS 1 arcs
a-idle.gcno:                  block 2: 3:0005(tree,fall)
a-idle.gcno:    01430000:  12:ARCS 1 arcs
a-idle.gcno:                  block 3: 4:0004(fall)
a-idle.gcno:    01430000:  12:ARCS 1 arcs
a-idle.gcno:                  block 4: 3:0005(tree,fall)
a-idle.gcno:    01450000:  31:LINES
a-idle.gcno:                  block 2:`idle.c':1

so with -O2 we only tract function entrance (idle.c:1) and it belongs to block
2, but the looping happens in BBs 3->4. So we loose the tracking.

Reply via email to