public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/108658] [GCOV] Function entry is not recorded in a function containing an infinite loop from another thread depending on the optimization level
Date: Thu, 09 Feb 2023 10:23:47 +0000	[thread overview]
Message-ID: <bug-108658-4-CY42bN57dG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108658-4@http.gcc.gnu.org/bugzilla/>

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.

      parent reply	other threads:[~2023-02-09 10:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 15:12 [Bug gcov-profile/108658] New: [GCOV] Function entry is not recorded in a function containing an infinite loop " sebastian.huber@embedded-brains.de
2023-02-03 15:23 ` [Bug gcov-profile/108658] " pinskia at gcc dot gnu.org
2023-02-03 16:36 ` pinskia at gcc dot gnu.org
2023-02-03 17:39 ` [Bug gcov-profile/108658] [GCOV] Function entry is not recorded in a function containing an infinite loop from another thread " sebastian.huber@embedded-brains.de
2023-02-03 18:28 ` sebastian.huber@embedded-brains.de
2023-02-06  9:20 ` marxin at gcc dot gnu.org
2023-02-06  9:56 ` rguenth at gcc dot gnu.org
2023-02-06  9:57 ` rguenth at gcc dot gnu.org
2023-02-09 10:23 ` marxin at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108658-4-CY42bN57dG@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).