public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/99440] New: [GCOV] Wrong coverage with callsite
@ 2021-03-07  7:36 dz1933028 at smail dot nju.edu.cn
  2021-03-08  9:10 ` [Bug gcov-profile/99440] " marxin at gcc dot gnu.org
  2021-08-06 11:39 ` njuwy at smail dot nju.edu.cn
  0 siblings, 2 replies; 3+ messages in thread
From: dz1933028 at smail dot nju.edu.cn @ 2021-03-07  7:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99440
           Summary: [GCOV] Wrong coverage with callsite
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dz1933028 at smail dot nju.edu.cn
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++
-disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC) 

$ cat test.c
#include <stdarg.h>

extern void abort(void);

int v1 = 8;
long int v2 = 3;
void *v3 = (void *)&v2;
struct A {
  char c[16];
} v4 = {"foo"};
long double v5 = 40;
char seen[20];
int cnt;

__attribute__((noinline)) int foo1(int x, int y, ...) {
  return x;
}

__attribute__((noinline)) int foo2(int x, int y, ...) {
  return x + 8;
}

__attribute__((noinline)) int foo3(void) { return 6; }

extern inline __attribute__((always_inline, gnu_inline)) int bar(int x, ...) {
  if (x < 10)
    return foo1(x, foo3(), 5, __builtin_va_arg_pack());
  return foo2(x, foo3() + 4, __builtin_va_arg_pack());
}

int main(void) {
  if (bar(0, ++v1, v4, &v4, v2++) != 0)
    abort();
  if (bar(1, ++v5, 8, v3) != 1)
    abort();
  if (bar(2) != 2)
    abort();
  if (bar(v1 + 2) != 19)
    abort();
  if (bar(v1 + 3, v5--, v4, v4, v3, 16LL) != 20)
    abort();
  return 0;
}


$ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
File 'test.c'
Lines executed:75.00% of 20
Creating 'test.c.gcov'

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        -:    1:#include <stdarg.h>
        -:    2:
        -:    3:extern void abort(void);
        -:    4:
        -:    5:int v1 = 8;
        -:    6:long int v2 = 3;
        -:    7:void *v3 = (void *)&v2;
        -:    8:struct A {
        -:    9:  char c[16];
        -:   10:} v4 = {"foo"};
        -:   11:long double v5 = 40;
        -:   12:char seen[20];
        -:   13:int cnt;
        -:   14:
        3:   15:__attribute__((noinline)) int foo1(int x, int y, ...) {
        3:   16:  return x;
        -:   17:}
        -:   18:
        2:   19:__attribute__((noinline)) int foo2(int x, int y, ...) {
        2:   20:  return x + 8;
        -:   21:}
        -:   22:
        5:   23:__attribute__((noinline)) int foo3(void) { return 6; }
        -:   24:
        -:   25:extern inline __attribute__((always_inline, gnu_inline)) int
bar(int x, ...) {
        1:   26:  if (x < 10)
       3*:   27:    return foo1(x, foo3(), 5, __builtin_va_arg_pack());
       2*:   28:  return foo2(x, foo3() + 4, __builtin_va_arg_pack());
        -:   29:}
        -:   30:
        1:   31:int main(void) {
        2:   32:  if (bar(0, ++v1, v4, &v4, v2++) != 0)
    #####:   33:    abort();
        2:   34:  if (bar(1, ++v5, 8, v3) != 1)
    #####:   35:    abort();
        1:   36:  if (bar(2) != 2)
    #####:   37:    abort();
        2:   38:  if (bar(v1 + 2) != 19)
    #####:   39:    abort();
        2:   40:  if (bar(v1 + 3, v5--, v4, v4, v3, 16LL) != 20)
    #####:   41:    abort();
        1:   42:  return 0;
        -:   43:}

The coverage of line #32,#34,#38 and #40 should be 1 like line #36

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

* [Bug gcov-profile/99440] [GCOV] Wrong coverage with callsite
  2021-03-07  7:36 [Bug gcov-profile/99440] New: [GCOV] Wrong coverage with callsite dz1933028 at smail dot nju.edu.cn
@ 2021-03-08  9:10 ` marxin at gcc dot gnu.org
  2021-08-06 11:39 ` njuwy at smail dot nju.edu.cn
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-03-08  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-03-08

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

* [Bug gcov-profile/99440] [GCOV] Wrong coverage with callsite
  2021-03-07  7:36 [Bug gcov-profile/99440] New: [GCOV] Wrong coverage with callsite dz1933028 at smail dot nju.edu.cn
  2021-03-08  9:10 ` [Bug gcov-profile/99440] " marxin at gcc dot gnu.org
@ 2021-08-06 11:39 ` njuwy at smail dot nju.edu.cn
  1 sibling, 0 replies; 3+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2021-08-06 11:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
And also line 26 should be executed 5 times

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

end of thread, other threads:[~2021-08-06 11:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07  7:36 [Bug gcov-profile/99440] New: [GCOV] Wrong coverage with callsite dz1933028 at smail dot nju.edu.cn
2021-03-08  9:10 ` [Bug gcov-profile/99440] " marxin at gcc dot gnu.org
2021-08-06 11:39 ` njuwy at smail dot nju.edu.cn

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).