public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/108658] New: [GCOV] Function entry is not recorded in a function containing an infinite loop depending on the optimization level
@ 2023-02-03 15:12 sebastian.huber@embedded-brains.de
  2023-02-03 15:23 ` [Bug gcov-profile/108658] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2023-02-03 15:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108658
           Summary: [GCOV] Function entry is not recorded in a function
                    containing an infinite loop depending on the
                    optimization level
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.huber@embedded-brains.de
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Consider the following test code:

idle.c

void *idle(void *ignored)
{
  while (1) {
    /* Do nothing */
  }

  return 0;
}

main.c

#include <unistd.h>

void *idle(void *ignored);

int main(void)
{
  pthread_t th;
  pthread_create(&th, NULL, idle, NULL);
  sleep(1);
  return 0;
}

This sequence of commands shows that the idle() function entry is not recorded
for -O2 and -Og:

gcc-12 -O2 --coverage -c main.c
rm -f *.gc??
gcc-12 -O2 --coverage -c idle.c
gcc-12 -pthread --coverage main.o idle.o
./a.out
gcov-12 idle.c
File 'idle.c'
Lines executed:0.00% of 1
Creating 'idle.c.gcov'

Lines executed:0.00% of 1
cat idle.c.gcov
        -:    0:Source:idle.c
        -:    0:Graph:idle.gcno
        -:    0:Data:idle.gcda
        -:    0:Runs:1
    #####:    1:void *idle(void *ignored)
        -:    2:{
        -:    3:  while (1) {
        -:    4:    /* Do nothing */
        -:    5:  }
        -:    6:
        -:    7:  return 0;
        -:    8:}
rm -f *.gc??
gcc-12 -Og --coverage -c idle.c
gcc-12 -pthread --coverage main.o idle.o
./a.out
gcov-12 idle.c
File 'idle.c'
Lines executed:50.00% of 2
Creating 'idle.c.gcov'

Lines executed:50.00% of 2
cat idle.c.gcov
        -:    0:Source:idle.c
        -:    0:Graph:idle.gcno
        -:    0:Data:idle.gcda
        -:    0:Runs:1
    #####:    1:void *idle(void *ignored)
        -:    2:{
472195650:    3:  while (1) {
        -:    4:    /* Do nothing */
        -:    5:  }
        -:    6:
        -:    7:  return 0;
        -:    8:}
rm -f *.gc??
gcc-12 -O0 --coverage -c idle.c
gcc-12 -pthread --coverage main.o idle.o
./a.out
gcov-12 idle.c
File 'idle.c'
Lines executed:100.00% of 2
Creating 'idle.c.gcov'

Lines executed:100.00% of 2
cat idle.c.gcov
        -:    0:Source:idle.c
        -:    0:Graph:idle.gcno
        -:    0:Data:idle.gcda
        -:    0:Runs:1
472440920:    1:void *idle(void *ignored)
        -:    2:{
472440920:    3:  while (1) {
        -:    4:    /* Do nothing */
        -:    5:  }
        -:    6:
        -:    7:  return 0;
        -:    8:}

For -O0 the line count is also wrong from my point of view. Line 1 should have
a count of 1.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-09 10:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 15:12 [Bug gcov-profile/108658] New: [GCOV] Function entry is not recorded in a function containing an infinite loop depending on the optimization level 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 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).