[Bug c/109520] New: compiler never terminate

2023-04-14 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109520

Bug ID: 109520
   Summary: compiler never terminate
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

Created attachment 54864
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54864=edit
triggering source code

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

$ cat small.c
#if defined __x86_64__
#define ASM(s) asm (s)
#else
#define ASM(s)
#endif

int
foo (int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8,
 int a9, int a10, int a11, int a12, int a13, int a14, int a15, int a16)
{
  register int v0 ASM ("rax") = a3;
  register int v1 ASM ("rbx") = a4;
  register int v2 ASM ("rcx") = a5;
  register int v3 ASM ("rdx") = a6;
  register int v4 ASM ("rsi") = a7;
  register int v5 ASM ("rdi") = a8;
  register int v6 ASM ("r8") = a9;
  register int v7 ASM ("r9") = a10;
  register int v8 ASM ("r10") = a11;
  register int v9 ASM ("r11") = a12;
  register int v10 ASM ("r12") = a13;
  register int v11 ASM ("r13") = a14;
  register int v12 ASM ("r14") = a15;
  register int v13 ASM ("r15") = a16;
  int x;

  v0 += a0;
  v1 += a1;
  v2 += a2;
  v0 |= a0;
  v1 |= a1;
  v2 |= a2;
  v0 ^= a0;
  v1 ^= a1;
  v2 ^= a2;
  v0 &= a0;
  v1 &= a1;
  v2 &= a2;
  asm goto ("": "=r" (x) : : : lab);
  a1 ^= a0;
  a2 = a1;
  a0 |= a2;
  a0 |= x;
 lab:
  v0 += x + a0 + a1 + a2;
  v1 -= a0 - a1 - a2;
  v2 |= a0 | a1 | a2;
  v3 |= a0 & a1 & a2;
  v4 ^= a0 ^ a1 ^ a2;
  return  v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10 + v11 + v12 +
v13 + a0 + a1 + a2;
}

$ gcc small.c

[Bug debug/90586] [gdb] gdb wrongly set the breakpoint as expected

2022-11-09 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90586

--- Comment #2 from Yibiao Yang  ---
(In reply to Richard Biener from comment #1)
> The reason is that somehow the only stmt with line 9 prevailing is one
> not originally having it:
> 
>:
>   [t.c:11:14] D.1918 = 0;
>   [t.c:11:14] // predicted unlikely by early return (on trees) predictor.
>   [t.c:9:11] g = {CLOBBER};
>   goto ; [INV]
> 
>:
>   [t.c:14:10] D.1918 = 0;
> 
>:
> :
>   return D.1918;
> 
> so the return stmt will end up inheriting it if we are "lucky".  try-finally
> lowering assigns the location, possibly simply taking the location of the
> last stmt from the "throw".

Thanks for the explanation. Thus, I was wondering that this bug should be
marked as "invalid"

[Bug debug/90584] [gdb] gdb is not stopped at a breakpoint in an executed line of code

2022-11-09 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

--- Comment #6 from Yibiao Yang  ---
Hi, Richard Biener. 

I updated gcc to the latest trunk version and also found that this bug seems
have been fixed in the following trunk version.

$ gcc --version
gcc (GCC) 13.0.0 20221107 (experimental)

I was wondering whether this bug can be also closed as fixed.

[Bug debug/95414] Wrong debug info for argc at -O2

2022-11-08 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95414

--- Comment #1 from Yibiao Yang  ---
Hi, @Richard Biener

I updated gcc to the latest trunk version and found that this bug seems have
been fixed in the following trunk version.

$ gcc --version
gcc (GCC) 13.0.0 20221107 (experimental)

I was wondering whether this bug can be closed as fixed.

[Bug gcov-profile/93680] [GCOV] "do-while" structure in case statement leads to incorrect code coverage

2022-09-08 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93680

Yibiao Yang  changed:

   What|Removed |Added

 CC||yangyibiao at nju dot edu.cn

--- Comment #3 from Yibiao Yang  ---
(In reply to Sunil Kumar from comment #2)
> I have executed same code in gcc 7.4.0 and i do not see the same behaviour.
> The case labels are properly marked as executed 5 times. please can you
> confirm this behaviour. And also the issues which are open items in gcov
> bugzilla list and reported in later gcc 7.4.0 version will those are
> applicable to gcc 7.4.0 ?

I do not check whether this problem is in gcc 7.4.0. This problem is found in
gcc version 9.2.0 (GCC). I re-check it in the trunk version and have the same
behavior as in gcc 9.2.0.

[Bug gcov-profile/97923] [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines

2022-09-08 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97923

--- Comment #4 from Yibiao Yang  ---
(In reply to Martin Liška from comment #3)
> Really, I see still the same:
> 
> $ gcc --version
> gcc (GCC) 13.0.0 20220908 (experimental)
> $ gcc -O0 --coverage test.c; ./a.out; gcov a-test.c; cat test.c.gcov
> File 'test.c'
> Lines executed:80.00% of 5
> Creating 'test.c.gcov'
> 
> Lines executed:80.00% of 5
> -:0:Source:test.c
> -:0:Graph:a-test.gcno
> -:0:Data:a-test.gcda
> -:0:Runs:1
> 1:1:int foo(int c)
> -:2:{
> #:3:  return ((c >= 'A' && c <= 'Z')
>1*:4:   || (c >= 'a' && c <= 'z')
>2*:5:   || (c >= '0' && c <= '0'));
> -:6:}
> -:7:
> 1:8:int main() { foo(0); }

Indeed, still the same. Sorry for this misleading info.

[Bug gcov-profile/97923] [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines

2022-09-08 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97923

Yibiao Yang  changed:

   What|Removed |Added

 CC||yangyibiao at nju dot edu.cn

--- Comment #2 from Yibiao Yang  ---
In the trunk version, Line #5 has no coverage info which considered as
''safe''. 
I was wondering taht whether this bug can be marked as fixed.

[Bug gcov-profile/105500] New: [Gcov]wrong freqency for the while loop with struct in the expression

2022-05-05 Thread yangyibiao at nju dot edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105500

Bug ID: 105500
   Summary: [Gcov]wrong freqency for the while loop with struct in
the expression
   Product: gcc
   Version: 7.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
struct S { int f; } a;

struct S foo (int x, struct S y)
{
  int b = y.f;
  return a; 
}

void bar ()
{
  while (a.f)
{
  struct S c = {0};
  foo (0, c);
}
}

int main ()
{
  bar (); 
  return 0;
}

$ gcc -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:54.55% of 11
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct S { int f; } a;
-:2:
#:3:struct S foo (int x, struct S y)
-:4:{
#:5:  int b = y.f;
#:6:  return a; 
-:7:}
-:8:
1:9:void bar ()
-:   10:{
2:   11:  while (a.f)
-:   12:{
#:   13:  struct S c = {0};
#:   14:  foo (0, c);
-:   15:}
1:   16:}
-:   17:
1:   18:int main ()
-:   19:{
1:   20:  bar (); 
1:   21:  return 0;
-:   22:}

Line #11 is wrongly marked as executed twice which should be executed once.

[Bug debug/91295] New: [gdb] program crashed with segementation fault when set breakpoint at address

2019-07-29 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91295

Bug ID: 91295
   Summary: [gdb] program crashed with segementation fault when
set breakpoint at address
   Product: gcc
   Version: 8.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.3.0-6ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1~18.04.1) 

$ gdb -v
GNU gdb (Ubuntu 8.2-0ubuntu1~18.04) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ cat small.c
#include 

int main()
{
  for (int *p = (int[]){ 1, 2, 3, 0 }; /* { dg-error "array" } */
   *p; ++p) {
printf("%d\n", *p);
  }
  return 0;
}

$ gcc -g small.c && gdb -batch -x cmds a.out
Breakpoint 1 at 0x553

Program received signal SIGSEGV, Segmentation fault.
0x77a05980 in __vdso_platform_setup () at
../sysdeps/unix/sysv/linux/x86_64/init-first.c:36
36  ../sysdeps/unix/sysv/linux/x86_64/init-first.c: No such file or
directory.
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 6324) killed]


##
Error: gdb set breakpoint and program crashed wiht segmentation fault
##

$ cat cmds
break *_init+0xb
run
kill
q

[Bug debug/90584] [gdb] gdb is not stopped at a breakpoint in an executed line of code

2019-05-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

Yibiao Yang  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #5 from Yibiao Yang  ---
According to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90574

This should be also a valid bug report. I change the status of this bug report
as unconfirmed.

[Bug debug/90574] [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

2019-05-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90574

--- Comment #2 from Yibiao Yang  ---
(In reply to Richard Biener from comment #1)
> We somehow build a broken(?) CFG from the start:
> 
> ;;   basic block 2, loop depth 0
> ;;pred:   ENTRY
>   if (argc == 0)
> ;;succ:   3
> 
> ;;   basic block 3, loop depth 0
> ;;pred:   2
> label:
>   if (argc == 1)
> goto ; [INV]
>   else
> goto ; [INV]
> 
> see how BB2 only has a single outgoing edge.  CFG cleanup fixes this for us.
> 
> .gimple has
> 
>   [t.c:2:1] {
> void label = <<< error >>>;
> 
> [t.c:3:6] if (argc == 0) goto ; else goto ;
> :
> [t.c:4:5] {
>   int * ptr;
> 
>   [t.c:6:1] label:
> }
> :
> [t.c:10:6] if (argc == 1) goto ; else goto ;
> 
> so that looks good, likewise .lower:
> 
>   [t.c:3:6] if (argc == 0) goto ; else goto ;
>   :
>   [t.c:6:1] label:
>   :
>   [t.c:10:6] if (argc == 1) goto ; else goto ;
> 
> iff we'd elide an empty block as having no side-effects we would have
> deleted the label.
> 
> Thus confirmed as CFG build bug.

Thanks for the comfirmation. 
Another bug I reported seems also a valid bug with a different code structure.
I am not quite sure whether it is a valid or not. 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

[Bug debug/90584] [gdb] gdb is not stopped at a breakpoint in an executed line of code

2019-05-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

--- Comment #4 from Yibiao Yang  ---
(In reply to Jonathan Wakely from comment #3)
> Putting "[gdb]" in the bug summary suggests you're trying to report a GDB
> bug, which doesn't belong here.
> 
> You're trying to put a breakpoint on a line with no code, which won't work.
> Try breaking on line 12.

Thanks. 
Indeed, as you said, I would probably agree that this is a bug in gdb. In fact,
we can set breakpoint at the label statement (Line 13) as follows. The behavior
of gdb is correct in this case. Thus, this problem should not be caused by "a
line with no code".

$ cat small.c
#include 
int main()
{
  int i = 0;
  int j = 0;
  for (; i<=1; i++) {
for (; j<=1; j++) {
  goto lbl;
}
  }

  printf("hello\n");
lbl:  // line 13
  return 0;
}

[Bug debug/90584] [gdb] gdb is not stopped at a breakpoint in an executed line of code

2019-05-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

--- Comment #2 from Yibiao Yang  ---
(In reply to Jonathan Wakely from comment #1)
> GDB is a separate project with its own bugzilla, see
> https://sourceware.org/bugzilla

Thanks. 
I am not quite sure whether this is a bug of gdb or gcc. 
I am wondering that the problem is caused by wrong code generated by gcc.

[Bug debug/90586] New: [gdb] gdb wrongly set the breakpoint as expected

2019-05-22 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90586

Bug ID: 90586
   Summary: [gdb] gdb wrongly set the breakpoint as expected
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/10.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 10.0.0 20190517 (experimental) (GCC)

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.

$ cat small.c
int c() 
{
  int b = 1;
f:
  if (b) {
short g[1];
for (; b < 0;) {
  goto f;
  return 0; // line 9
}
return 0;
  } else
;
  return 0;
}

void main() 
{ 
  c();
}

$ gcc -O0 -g small.c;  gdb -batch -x cmds a.out
Breakpoint 1 at 0x40049b: file small.c, line 9.

Breakpoint 1, c () at small.c:11
11  return 0;
g = {64}
b = 1
Kill the program being debugged? (y or n) [answered Y; input not from terminal]

$ cat cmds
b 9
r
info locals
kill
q


=
We set breakpoint at line 9 "b 9" in cmds. Line #9 is never executed. Thus, the
expected behavior should be exit normally. However, it stopped at line 11. We
are not set breakpoint in line 11. Thus, I was wondering this is a bug in gdb.

[Bug debug/90584] New: [gdb] gdb is not stopped at a breakpoint in an executed line of code

2019-05-22 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90584

Bug ID: 90584
   Summary: [gdb] gdb is not stopped at a breakpoint in an
executed line of code
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

$ gcc --version
gcc (GCC) 10.0.0 20190517 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gdb --version
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.


$ cat small.c
#include 
int main()
{
  int i = 0;
  int j = 0;
  for (; i<=1; i++) {
for (; j<=1; j++) {
  goto lbl;
}
  }
lbl:  // line 11
  printf("hello\n");
  return 0;
}

$ gcc -O0 -g small.c; ./a.out
hello

$ gdb -batch -x cmds a.out
Breakpoint 1 at 0x40051a: file small.c, line 11.
hello
[Inferior 1 (process 2774) exited normally]
cmds:3: Error in sourced command file:
No frame selected.

$ cat cmds
b 11
r
info locals
kill
q

According to the program output, Line 11 should be executed. Thus, when we set
breakpoint at line 11, it should be stopped and print something. However, the
program executed and exit directly.

[Bug debug/90574] New: [gdb] gdb wrongly stopped at a breakpoint in an unexecuted line of code

2019-05-22 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90574

Bug ID: 90574
   Summary: [gdb] gdb wrongly stopped at a breakpoint in an
unexecuted line of code
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: debug
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
  Target Milestone: ---

$ gcc --version
gcc (GCC) 10.0.0 20190517 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gdb --version
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

$ cat small.c
#include 

int main(int argc, char **argv)
{
  if (argc == 0)
  {
int *ptr;
label:
  {
  }
  }
  if (argc == 1)
  {
 printf("hello\n");
  }
  return 0;
}

$ gcc -g small.c; ./a.out
hello

$ gdb -batch -x cmds a.out
Breakpoint 1 at 0x400501: file small.c, line 8.

Breakpoint 1, main (argc=1, argv=0x7fffde58) at small.c:8
8   label:
ptr = 
Kill the program being debugged? (y or n) [answered Y; input not from terminal]


$ cat cmds
b 8
r
info locals
kill
q


Line 8 in the body of the "if (argc==0)" is not executed according to the
program output. 

Thus, when we set breakpoint in Line #8, gdb should not stop. However, in this
case, it stopped and print something. Thus, I was wondering this should be a
bug in gdb.

[Bug gcov-profile/90438] [GCOV] switch statement is not instrumented when "case" body is empty and only "default" body with statements

2019-05-13 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90438

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> It's again the same story. As I've already explained you multiple times,
> compiler optimizes a dead code even without any optimization level. Thus we
> 
> Please do not create such bugs.

Very sorry for the same bug report. Will avoid in the future. 

Thank you very much for the detailed explaination.

[Bug gcov-profile/90439] New: [GCOV] multiple expression across different lines in if statement is inconsistent when the body is empty

2019-05-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90439

Bug ID: 90439
   Summary: [GCOV] multiple expression across different lines in
if statement is inconsistent when the body is empty
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcov -v
gcov (GCC) 9.0.1 20190414 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.


$ cat small.c
void test1 (int x, unsigned u)
{
  if ((1U << x) != 64
  || (2 << x) != u
  || (1 << x) == 14
  || (3 << 2) != 12)
; // __builtin_abort ();
}

int main (void)
{
  test1 (6, 128U);
}


$ gcc -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:void test1 (int x, unsigned u)
-:2:{
1:3:  if ((1U << x) != 64
1:4:  || (2 << x) != u
-:5:  || (1 << x) == 14
-:6:  || (3 << 2) != 12)
-:7:; // __builtin_abort ();
1:8:}
-:9:
1:   10:int main (void)
-:   11:{
1:   12:  test1 (6, 128U);
-:   13:}

Line #6 is marked as "-" which means that it is not an instrumentation site.
When Line #7 is not removed, it is marked as executed as follows. In other
words, it is now an instrumentation site. 

I know that when Line #7 is removed, empty body in if statement will lead to
compiler optimizations. But I am still confused by this inconsistency as Line
#4 and Line #3 are both marked as executed in both situations. 

$ gcc -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:void test1 (int x, unsigned u)
-:2:{
1:3:  if ((1U << x) != 64
1:4:  || (2 << x) != u
-:5:  || (1 << x) == 14
1:6:  || (3 << 2) != 12)
#:7:__builtin_abort ();
1:8:}
-:9:
1:   10:int main (void)
-:   11:{
1:   12:  test1 (6, 128U);
-:   13:}

[Bug gcov-profile/90438] New: [GCOV] switch statement is not instrumented when "case" body is empty and only "default" body with statements

2019-05-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90438

Bug ID: 90438
   Summary: [GCOV] switch statement is not instrumented when
"case" body is empty and only "default" body with
statements
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcov -v
gcov (GCC) 9.0.1 20190414 (experimental)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:int f(int i)
-:2:{
-:3:  int res;
-:4:
-:5:  switch (i)
-:6:{
-:7:case 5:
-:8:  // res = i - i;
-:9:  // break;
-:   10:default:
1:   11:  res = i * 2;
1:   12:  break;
-:   13:}
-:   14:
1:   15:  return res;
-:   16:}
-:   17:
1:   18:int main(void)
-:   19:{
1:   20:  f(2);
1:   21:  return 0;
-:   22:}

I was wondering that Line #5 in this code should be an instrumentation site.
Thus, I think this line should be marked as executed. 
When Line #8 and Line #9 are not removed, Line #5 is became an instrumentation
site as follows:

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

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:int f(int i)
-:2:{
-:3:  int res;
-:4:
1:5:  switch (i)
-:6:{
#:7:case 5:
#:8:  res = i - i;
#:9:  break;
1:   10:default:
1:   11:  res = i * 2;
1:   12:  break;
-:   13:}
-:   14:
1:   15:  return res;
-:   16:}
-:   17:
1:   18:int main(void)
-:   19:{
1:   20:  f(2);
1:   21:  return 0;
-:   22:}

[Bug gcov-profile/90425] [GCOV] wrong coverage for complicated function call in if expression when the abort() statement is in the body of if statement

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90425

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> Confirmed, we already have a duplicate for it. It's about trailing '||'
> operator.
> Following is fine:
> 
> -:4:int
> 1:5:main ()
> -:6:{
> 1:7:  long a = 0x89ABCDEF;
> -:8:
> 1:9:  if (f1(a)!=0x8900L
> 1:   10:  || f6(a)!=0x89ABL)
> #:   11:__builtin_abort();
> 1:   12:  __builtin_exit(0);
> -:   13:}

Got it. Thanks a lot.

[Bug gcov-profile/90425] New: [GCOV] wrong coverage for complicated function call in if expression when the abort() statement is in the body of if statement

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90425

Bug ID: 90425
   Summary: [GCOV] wrong coverage for complicated function call in
if expression when the abort() statement is in the
body of if statement
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot 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/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 9.0.1 20190414 (experimental) (GCC)

$ cat small.c
long f1(long a){return a&0xff00L;}
long f6(long a){return a&~0xL;}

main ()
{
  long a = 0x89ABCDEF;

  if (f1(a)!=0x8900L||
  f6(a)!=0x89ABL)
; // abort();
  exit(0);
}

$ gcc -w -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:long f1(long a){return a&0xff00L;}
1:2:long f6(long a){return a&~0xL;}
-:3:
1:4:main ()
-:5:{
1:6:  long a = 0x89ABCDEF;
-:7:
2:8:  if (f1(a)!=0x8900L||
1:9:  f6(a)!=0x89ABL)
#:   10:abort();
1:   11:  exit(0);
-:   12:}

It seems that line #8 might be "wrongly" marked as executed twice. 

When Line #10 is removed, the coverage of line #8 seems to be correct as
follows:

$ gcc -w -O0 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:long f1(long a){return a&0xff00L;}
1:2:long f6(long a){return a&~0xL;}
-:3:
1:4:main ()
-:5:{
1:6:  long a = 0x89ABCDEF;
-:7:
1:8:  if (f1(a)!=0x8900L||
1:9:  f6(a)!=0x89ABL)
-:   10:; // abort();
1:   11:  exit(0);
-:   12:}

[Bug gcov-profile/90420] [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

--- Comment #8 from Yibiao Yang  ---
(In reply to Martin Liška from comment #7)
> > Line #5 is marked as not executed. I understand that this function might be
> > optimized as an inline function. However, since Line #7 and Line #8 is
> > marked as executed and Line #5 is marked as not executed. This might mislead
> > others when debugging or testing based on code coverage.
> 
> That's the nature of any optimizing compiler. If you want to have the best
> results, then don't use -O2, or any other optimization level.

Got it. Thanks a lot.

[Bug gcov-profile/90420] [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

--- Comment #6 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> > $ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
> > File 'small.c'
> > Lines executed:78.57% of 14
> > Creating 'small.c.gcov'
> > 
> > -:0:Source:small.c
> > -:0:Graph:small.gcno
> > -:0:Data:small.gcda
> > -:0:Runs:1
> > -:1:#define N 1000
> > -:2:
> > -:3:int argc = 1;
> > -:4:
> > #:5:int func (int *p, int *q) {
> > 1001*:6:  int x = 0;
> > #:7:  for (int i = 0; i < N; i++) { 
> > 1000*:8:x += (q[i] + p[i]);
> > -:9:  }
> >1*:   10:  return x;
> > -:   11:}
> > -:   12:
> > 1:   13:int main ()
> > -:   14:{
> > 1:   15:  int x = 0;
> > 1:   16:  int A1[N], A2[N];
> > -:   17:
> >  1001:   18:  for (int i = 0; i < N; i++) {
> >  1000:   19:A1[i] = 5 + argc;
> >  1000:   20:A2[i] = 1;
> > -:   21:  }
> > -:   22:  
> >  1001:   23:  x = func (A1, A2);
> > -:   24:
> > 1:   25:  if (x != N * 7)
> > #:   26:return 1;
> > -:   27:
> > -:   28:  return 0;
> > -:   29:}
> > 
> > 
> > When using "-O3" optimization, Line #6 and Line #22 are wrongly marked as
> 
> I can't see Line #22 being executed.
> 
> With 9.1.0 I see:
> 
> -:0:Source:pr90420.c
> -:0:Graph:pr90420.gcno
> -:0:Data:pr90420.gcda
> -:0:Runs:1
> -:1:#define N 1000
> -:2:
> -:3:int argc = 1;
> -:4:
> #:5:int func (int *p, int *q) {
> -:6:  int x = 0;
> 1001*:7:  for (int i = 0; i < N; i++) { 
> 1000*:8:x += (q[i] + p[i]);
> -:9:  }
> #:   10:  return x;
> -:   11:}
> -:   12:
> 1:   13:int main ()
> -:   14:{
> -:   15:  int x = 0;
> -:   16:  int A1[N], A2[N];
> -:   17:
>  1001:   18:  for (int i = 0; i < N; i++) {
>  1000:   19:A1[i] = 5 + argc;
>  1000:   20:A2[i] = 1;
> -:   21:  }
> -:   22:  
> -:   23:  x = func (A1, A2);
> -:   24:
> 1:   25:  if (x != N * 7)
> #:   26:return 1;
> -:   27:
> -:   28:  return 0;
> -:   29:}
> 
> which should be reasonable good.


of this code :

 #:5:int func (int *p, int *q) {
 -:6:  int x = 0;
 1001*:7:  for (int i = 0; i < N; i++) { 
 1000*:8:x += (q[i] + p[i]);
 -:9:  }
 #:   10:  return x;
 -:   11:}

Line #5 is marked as not executed. I understand that this function might be
optimized as an inline function. However, since Line #7 and Line #8 is marked
as executed and Line #5 is marked as not executed. This might mislead others
when debugging or testing based on code coverage.

[Bug gcov-profile/90420] [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

--- Comment #4 from Yibiao Yang  ---
(In reply to Martin Liška from comment #3)
> > > 
> > Sorry. It should be Line #23
> 
> Which is fine in what I see.

I was wondering this line should executed only once as it is not nested in a
loop. ;-)

[Bug gcov-profile/90420] [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

2019-05-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> > $ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
> > File 'small.c'
> > Lines executed:78.57% of 14
> > Creating 'small.c.gcov'
> > 
> > -:0:Source:small.c
> > -:0:Graph:small.gcno
> > -:0:Data:small.gcda
> > -:0:Runs:1
> > -:1:#define N 1000
> > -:2:
> > -:3:int argc = 1;
> > -:4:
> > #:5:int func (int *p, int *q) {
> > 1001*:6:  int x = 0;
> > #:7:  for (int i = 0; i < N; i++) { 
> > 1000*:8:x += (q[i] + p[i]);
> > -:9:  }
> >1*:   10:  return x;
> > -:   11:}
> > -:   12:
> > 1:   13:int main ()
> > -:   14:{
> > 1:   15:  int x = 0;
> > 1:   16:  int A1[N], A2[N];
> > -:   17:
> >  1001:   18:  for (int i = 0; i < N; i++) {
> >  1000:   19:A1[i] = 5 + argc;
> >  1000:   20:A2[i] = 1;
> > -:   21:  }
> > -:   22:  
> >  1001:   23:  x = func (A1, A2);
> > -:   24:
> > 1:   25:  if (x != N * 7)
> > #:   26:return 1;
> > -:   27:
> > -:   28:  return 0;
> > -:   29:}
> > 
> > 
> > When using "-O3" optimization, Line #6 and Line #22 are wrongly marked as
> 
> I can't see Line #22 being executed.
> 
Sorry. It should be Line #23

[Bug gcov-profile/90420] New: [GCOV] wrong coverage with "-O3" or "-O2" optimizations for function call

2019-05-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420

Bug ID: 90420
   Summary: [GCOV] wrong coverage with "-O3" or "-O2"
optimizations for function call
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot 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/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 9.0.1 20190414 (experimental) (GCC)

$ cat small.c
#define N 1000

int argc = 1;

int func (int *p, int *q) {
  int x = 0;
  for (int i = 0; i < N; i++) { 
x += (q[i] + p[i]);
  }
  return x;
}

int main ()
{
  int x = 0;
  int A1[N], A2[N];

  for (int i = 0; i < N; i++) {
A1[i] = 5 + argc;
A2[i] = 1;
  }

  x = func (A1, A2);

  if (x != N * 7)
return 1;

  return 0;
}


$ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:78.57% of 14
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:1:#define N 1000
-:2:
-:3:int argc = 1;
-:4:
#:5:int func (int *p, int *q) {
1001*:6:  int x = 0;
#:7:  for (int i = 0; i < N; i++) { 
1000*:8:x += (q[i] + p[i]);
-:9:  }
   1*:   10:  return x;
-:   11:}
-:   12:
1:   13:int main ()
-:   14:{
1:   15:  int x = 0;
1:   16:  int A1[N], A2[N];
-:   17:
 1001:   18:  for (int i = 0; i < N; i++) {
 1000:   19:A1[i] = 5 + argc;
 1000:   20:A2[i] = 1;
-:   21:  }
-:   22:  
 1001:   23:  x = func (A1, A2);
-:   24:
1:   25:  if (x != N * 7)
#:   26:return 1;
-:   27:
-:   28:  return 0;
-:   29:}


When using "-O3" optimization, Line #6 and Line #22 are wrongly marked as
executed about 1000 times. When using "-O2" optimization, the coverage result
is incorrect as well. 

When Line #26 is removed, the result seems correct as follows:

$ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:75.00% of 12
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:1:#define N 1000
-:2:
-:3:int argc = 1;
-:4:
#:5:int func (int *p, int *q) {
   1*:6:  int x = 0;
#:7:  for (int i = 0; i < N; i++) { 
#:8:x += (q[i] + p[i]);
-:9:  }
   1*:   10:  return x;
-:   11:}
-:   12:
1:   13:int main ()
-:   14:{
1:   15:  int x = 0;
1:   16:  int A1[N], A2[N];
-:   17:
1:   18:  for (int i = 0; i < N; i++) {
-:   19:A1[i] = 5 + argc;
-:   20:A2[i] = 1;
-:   21:  }
-:   22:
1:   23:  x = func (A1, A2);
-:   24:
1:   25:  if (x != N * 7)
-:   26:; // return 1;
-:   27:
1:   28:  return 0;
-:   29:}

[Bug gcov-profile/89673] [GCOV] A label followed with a blank(empty) statement will be wrongly marked as executed in gcov

2019-05-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89673

--- Comment #4 from Yibiao Yang  ---
(In reply to Martin Liška from comment #3)
> (In reply to Yibiao Yang from comment #2)
> > (In reply to Martin Liška from comment #1)
> > > Confirmed, again an empty label, thus we generate not precise results.
> > 
> > I am not sure whether this is really a bug or only default behavior of gcov.
> 
> Technically it's a bug, but for me with a very low priority.
> 
> > 
> > Since these two labels are close to each other and the first label is
> > followed with empty statement, it is reasonable to combine these two labels
> > together. Thus, I am wondering this is the default behavior of gcov. Am I
> > right?
> 
> As mentioned multiple times, GCC is optimizing code even with -O0 and so
> that the empty ';' statement would be optimized out.

Got it. Thank you very much for the detailed explanation.

[Bug gcov-profile/89673] [GCOV] A label followed with a blank(empty) statement will be wrongly marked as executed in gcov

2019-05-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89673

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> Confirmed, again an empty label, thus we generate not precise results.

I am not sure whether this is really a bug or only default behavior of gcov. 

Since these two labels are close to each other and the first label is followed
with empty statement, it is reasonable to combine these two labels together.
Thus, I am wondering this is the default behavior of gcov. Am I right?

[Bug gcov-profile/90104] New: [GCOV] Wrong coverage for variable arguments function call statement while the function is inline function

2019-04-15 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90104

Bug ID: 90104
   Summary: [GCOV] Wrong coverage for variable arguments function
call statement while the function is inline function
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot 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/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 9.0.1 20190414 (experimental) (GCC) 

$ cat small.c
#include 

extern void abort (void);
long x = 0, y = 0;

inline void __attribute__((always_inline))
f1i (va_list ap)
{
  x = va_arg (ap, double);
  x += va_arg (ap, long);
}

void f4 (int i, ...)
{
  va_list ap;

  va_start (ap, i);
  switch (i)
  {
case 4:
  y = va_arg (ap, double);
  break;
case 5:
  y = va_arg (ap, double);
  y += va_arg (ap, double);
  break;
default:
  ; // abort ();
  }
  f1i (ap);
  va_end (ap);
}

int main ()
{
  f4 (4, 6.0, 9.0, 16L, 18.0);
  return 0;
}

$ rm small.g*; gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat
small.c.gcov
File 'small.c'
Lines executed:78.95% of 19
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:1:#include 
-:2:
-:3:extern void abort (void);
-:4:long x = 0, y = 0;
-:5:
-:6:inline void __attribute__((always_inline))
-:7:f1i (va_list ap)
-:8:{
2:9:  x = va_arg (ap, double);
1:   10:  x += va_arg (ap, long);
1:   11:}
-:   12:
1:   13:void f4 (int i, ...)
-:   14:{
-:   15:  va_list ap;
-:   16:
1:   17:  va_start (ap, i);
1:   18:  switch (i)
-:   19:  {
1:   20:case 4:
1:   21:  y = va_arg (ap, double);
1:   22:  break;
#:   23:case 5:
#:   24:  y = va_arg (ap, double);
#:   25:  y += va_arg (ap, double);
#:   26:  break;
1:   27:default:
-:   28:  ; // abort ();
-:   29:  }
-:   30:  f1i (ap);
1:   31:  va_end (ap);
1:   32:}
-:   33:
1:   34:int main ()
-:   35:{
1:   36:  f4 (4, 6.0, 9.0, 16L, 18.0);
1:   37:  return 0;
-:   38:}

Line #9 is wrongly marked as executed twice. 

While Line #28 is removed, the result is correct as follows: 

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

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:1:#include 
-:2:
-:3:extern void abort (void);
-:4:long x = 0, y = 0;
-:5:
-:6:inline void __attribute__((always_inline))
-:7:f1i (va_list ap)
-:8:{
1:9:  x = va_arg (ap, double);
1:   10:  x += va_arg (ap, long);
1:   11:}
-:   12:
1:   13:void f4 (int i, ...)
-:   14:{
-:   15:  va_list ap;
-:   16:
1:   17:  va_start (ap, i);
1:   18:  switch (i)
-:   19:  {
1:   20:case 4:
1:   21:  y = va_arg (ap, double);
1:   22:  break;
#:   23:case 5:
#:   24:  y = va_arg (ap, double);
#:   25:  y += va_arg (ap, double);
#:   26:  break;
#:   27:default:
#:   28:  abort ();
-:   29:  }
-:   30:  f1i (ap);
1:   31:  va_end (ap);
1:   32:}
-:   33:
1:   34:int main ()
-:   35:{
1:   36:  f4 (4, 6.0, 9.0, 16L, 18.0);
1:   37:  return 0;
-:   38:}

[Bug gcov-profile/90092] New: [GCOV] Wrong frequencies then the default label in switch statement is followed with no statement

2019-04-15 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90092

Bug ID: 90092
   Summary: [GCOV] Wrong frequencies then the default label in
switch statement is followed with no statement
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot 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/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 9.0.1 20190414 (experimental) (GCC)

$ cat small.c
int bar (int a)
{
  int ret = 0;
  switch (a)
  {
case 1: ret = ret + 1; break;
default:
  ;// ret = ret + 2;
  }

  return ret;
}

int main ()
{
  bar(1);
  return 0;
}

$ gcc -w -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:int bar (int a)
-:2:{
1:3:  int ret = 0;
1:4:  switch (a)
-:5:  {
1:6:case 1: ret = ret + 1; break;
1:7:default:
-:8:  ;// ret = ret + 2;
-:9:  }
-:   10:
1:   11:  return ret;
-:   12:}
-:   13:
1:   14:int main ()
-:   15:{
1:   16:  bar(1);
1:   17:  return 0;
-:   18:}

Line #7 is wrongly marked as executed. It should be not executed. 

I am not quite sure this should be reported as a new bug report. As there has
similar bug report 85179 while a label statement is followed with no
statements. 

When the "default:" statement is not empty, the result is correct as:
$ gcc -w -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:int bar (int a)
-:2:{
1:3:  int ret = 0;
1:4:  switch (a)
-:5:  {
1:6:case 1: ret = ret + 1; break;
#:7:default:
#:8:  ret = ret + 2;
-:9:  }
-:   10:
1:   11:  return ret;
-:   12:}
-:   13:
1:   14:int main ()
-:   15:{
1:   16:  bar(1);
1:   17:  return 0;
-:   18:}

[Bug gcov-profile/90091] New: [GCOV] code formatting lead to incorrect code coverage for "if ( expr1 || expr2) " statement

2019-04-15 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90091

Bug ID: 90091
   Summary: [GCOV] code formatting lead to incorrect code coverage
for "if ( expr1 || expr2) " statement
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot 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/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 9.0.1 20190414 (experimental) (GCC)

$ cat small.c
long f1(long a){return a&0xff00L;}
long f2(long a){return a&~0xff00L;}

void main ()
{
  long a = 0x89ABCDEF;

  if (f1(a)!=0x8900L||
  f2(a)!=0x00ABCDEFL)
abort();
  exit(0);
}

$ gcc -w -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:long f1(long a){return a&0xff00L;}
1:2:long f2(long a){return a&~0xff00L;}
-:3:
1:4:void main ()
-:5:{
1:6:  long a = 0x89ABCDEF;
-:7:
2:8:  if (f1(a)!=0x8900L||
1:9:  f2(a)!=0x00ABCDEFL)
#:   10:abort();
1:   11:  exit(0);
-:   12:}


Line #8 is wrongly marked as executed twice. 

When Line #8 and Line #9 is in the same code line, the code coverage report is
correct as follows:
$ gcc -w -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
libgcov profiling error:/home/yyb/cv-emi/small.gcda:overwriting an existing
profile data with a different timestamp
File 'small.c'
Lines executed:85.71% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
1:1:long f1(long a){return a&0xff00L;}
1:2:long f2(long a){return a&~0xff00L;}
-:3:
1:4:void main ()
-:5:{
1:6:  long a = 0x89ABCDEF;
-:7:
1:8:  if (f1(a)!=0x8900L||f2(a)!=0x00ABCDEFL)
#:9:abort();
1:   10:  exit(0);
-:   11:}

[Bug gcov-profile/90066] New: [GCOV] function with inline attribute leading to incorrect coverage for the "if" statement

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90066

Bug ID: 90066
   Summary: [GCOV] function with inline attribute leading to
incorrect coverage for the "if" statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)


$ cat small.c
int check_int (int *i, int align)
{
  *i = 20;
  return *i;
}

typedef int aligned __attribute__((aligned(64)));

static void
inline __attribute__((always_inline))
foo (void)
{
  aligned i;
  if (check_int (, __alignof__(i)) != i)
; // abort ();
}

int main()
{
  foo ();
  return 0;
}


$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int check_int (int *i, int align)
-:2:{
1:3:  *i = 20;
1:4:  return *i;
-:5:}
-:6:
-:7:typedef int aligned __attribute__((aligned(64)));
-:8:
-:9:static void
-:   10:inline __attribute__((always_inline))
-:   11:foo (void)
-:   12:{
-:   13:  aligned i;
2:   14:  if (check_int (, __alignof__(i)) != i)
-:   15:; // abort ();
-:   16:}
-:   17:
1:   18:int main()
-:   19:{
-:   20:  foo ();
1:   21:  return 0;
-:   22:}


Line #14 is wrongly marked as executed twice. This statement should be only
executed once. 



1. While Line #10 @@inline __attribute__((always_inline))@@ is removed, the
result is correct as:
$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int check_int (int *i, int align)
-:2:{
1:3:  *i = 20;
1:4:  return *i;
-:5:}
-:6:
-:7:typedef int aligned __attribute__((aligned(64)));
-:8:
-:9:static void
-:   10:// inline __attribute__((always_inline))
1:   11:foo (void)
-:   12:{
-:   13:  aligned i;
1:   14:  if (check_int (, __alignof__(i)) != i)
-:   15:; // abort ();
1:   16:}
-:   17:
1:   18:int main()
-:   19:{
1:   20:  foo ();
1:   21:  return 0;
-:   22:}

2. While Line #12 is not removed, the result is also correct as: 
$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:85.71% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int check_int (int *i, int align)
-:2:{
1:3:  *i = 20;
1:4:  return *i;
-:5:}
-:6:
-:7:typedef int aligned __attribute__((aligned(64)));
-:8:
-:9:static void
-:   10:inline __attribute__((always_inline))
-:   11:foo (void)
-:   12:{
-:   13:  aligned i;
1:   14:  if 

[Bug gcov-profile/90053] [GCOV] A statement in while loop is wrongly marked as not executed when they are within the if(setjmp()) statement

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90053

--- Comment #2 from Yibiao Yang  ---
(In reply to Richard Biener from comment #1)
> I think you need to use setjmp/longjmp, not the __builtin variants which have
> special semantics.

Thanks for the suggestion. This is a reduced version of the test program in the
gcc testsuite: gcc-7.4.0/gcc/testsuite/gcc.dg/setjmp-2.c

[Bug gcov-profile/90054] [GCOV] A call statement to the __builtin_snprintf function is wrongly marked as not executed when it is in a for loop

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90054

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> Fixed on trunk with r263111. Not planning to backport.

Got it. Thanks a lot.

[Bug gcov-profile/90057] New: [GCOV] Wrong coverage for "if()" statement while it is embedded with an empty "for(;0;)" loop statement

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90057

Bug ID: 90057
   Summary: [GCOV] Wrong coverage for "if()" statement while it is
embedded with an empty "for(;0;)" loop statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c

int main()
{
  int b = 0, d = 0, f = 0, p = -1;

  if (f > p && p)
for (; 0;)
   ;
  else if (d)
b = 0 >= b;

  return 0;
}

$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:71.43% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:
1:2:int main()
-:3:{
1:4:  int b = 0, d = 0, f = 0, p = -1;
-:5:
2:6:  if (f > p && p)
1:7:for (; 0;)
-:8:   ;
#:9:  else if (d)
#:   10:b = 0 >= b;
-:   11:
1:   12:  return 0;
-:   13:}

Line #6 is wrongly marked as executed twice. 

While Line 7 is removed. The result is correct as:
$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:66.67% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:
1:2:int main()
-:3:{
1:4:  int b = 0, d = 0, f = 0, p = -1;
-:5:
1:6:  if (f > p && p)
-:7:// for (; 0;)
-:8:   ;
#:9:  else if (d)
#:   10:b = 0 >= b;
-:   11:
1:   12:  return 0;
-:   13:}

While Line #9 and Line #10 are both removed, the result is also correct as:
$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:
1:2:int main()
-:3:{
1:4:  int b = 0, d = 0, f = 0, p = -1;
-:5:
1:6:  if (f > p && p)
1:7:for (; 0;)
-:8:   ;
-:9:  // else if (d)
-:   10:  //   b = 0 >= b;
-:   11:
1:   12:  return 0;
-:   13:}

[Bug gcov-profile/90054] New: [GCOV] A call statement to the __builtin_snprintf function is wrongly marked as not executed when it is in a for loop

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90054

Bug ID: 90054
   Summary: [GCOV] A call statement to the __builtin_snprintf
function is wrongly marked as not executed when it is
in a for loop
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int b = 1, d = 2;
char res[2];

void fn3 ()
{
  for (;;)
  {
__builtin_snprintf (res, 2, "%d\n", d);
if (d)
  break;
  }
  printf("%s\n", res);
}

int main ()
{
  fn3 ();
  return 0;
}

$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
2
File 'small.c'
Lines executed:88.89% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int b = 1, d = 2;
-:2:char res[2];
-:3:
1:4:void fn3 ()
-:5:{
-:6:  for (;;)
-:7:  {
#:8:__builtin_snprintf (res, 2, "%d\n", d);
1:9:if (d)
1:   10:  break;
-:   11:  }
1:   12:  printf("%s\n", res);
1:   13:}
-:   14:
1:   15:int main ()
-:   16:{
1:   17:  fn3 ();
1:   18:  return 0;
-:   19:}

Line #8 is wrongly marked as not executed. 

When the builtin_snprintf function is replaced with snprintf function, the
coverage report is correct as:

$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
2
File 'small.c'
Lines executed:90.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int b = 1, d = 2;
-:2:char res[2];
-:3:
1:4:void fn3 ()
-:5:{
-:6:  for (;;)
#:7:  {
-:8:// __builtin_snprintf (res, 2, "%d\n", d);
1:9:snprintf (res, 2, "%d\n", d);
1:   10:if (d)
1:   11:  break;
-:   12:  }
1:   13:  printf("%s\n", res);
1:   14:}
-:   15:
1:   16:int main ()
-:   17:{
1:   18:  fn3 ();
1:   19:  return 0;
-:   20:}

[Bug gcov-profile/90053] New: [GCOV] A statement in while loop is wrongly marked as not executed when they are within the if(setjmp()) statement

2019-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90053

Bug ID: 90053
   Summary: [GCOV] A statement in while loop is wrongly marked as
not executed when they are within the if(setjmp())
statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
#include 
#include 
#include 

static jmp_buf segv_jmpbuf;
static void segv_handler(int seg) {  __builtin_longjmp(segv_jmpbuf, 1); }

static int is_addressable(void *p, size_t size)
{
   volatile char * volatile cp = (volatile char *)p;
   volatile int ret;
   struct sigaction sa, origsa;
   sigset_t mask;

   sa.sa_handler = segv_handler;
   sa.sa_flags = 0;
   sigfillset(_mask);
   sigaction(SIGSEGV, , );
   sigprocmask(SIG_SETMASK, NULL, );

   if (__builtin_setjmp(segv_jmpbuf) == 0) {
  printf("size: %d\n", size);
  while(size--)
  {  *cp++; }
  ret = 1;
   } else {
  ret = 0;
   }

   sigaction(SIGSEGV, , NULL);
   sigprocmask(SIG_SETMASK, , NULL);

   return ret;
}

int main(int argc, char **argv)
{
   is_addressable(0x0, 1);
   return 0;
}

$ gcc -w -O0 --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
size: 1
File 'small.c'
Lines executed:95.00% of 20
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:#include 
-:3:#include 
-:4:
-:5:static jmp_buf segv_jmpbuf;
1:6:static void segv_handler(int seg) { 
__builtin_longjmp(segv_jmpbuf, 1); }
-:7:
1:8:static int is_addressable(void *p, size_t size)
-:9:{
1:   10:   volatile char * volatile cp = (volatile char *)p;
-:   11:   volatile int ret;
-:   12:   struct sigaction sa, origsa;
-:   13:   sigset_t mask;
-:   14:
1:   15:   sa.sa_handler = segv_handler;
1:   16:   sa.sa_flags = 0;
1:   17:   sigfillset(_mask);
1:   18:   sigaction(SIGSEGV, , );
1:   19:   sigprocmask(SIG_SETMASK, NULL, );
-:   20:
2:   21:   if (__builtin_setjmp(segv_jmpbuf) == 0) {
1:   22:  printf("size: %d\n", size);
1:   23:  while(size--)
#:   24:  {  *cp++; }
1:   25:  ret = 1;
-:   26:   } else {
1:   27:  ret = 0;
-:   28:   }
-:   29:
2:   30:   sigaction(SIGSEGV, , NULL);
1:   31:   sigprocmask(SIG_SETMASK, , NULL);
-:   32:
1:   33:   return ret;
-:   34:}
-:   35:
1:   36:int main(int argc, char **argv)
-:   37:{
1:   38:   is_addressable(0x0, 1);
1:   39:   return 0;
-:   40:}

Line #24 is wrongly marked as not executed. The value of variable #size# is 1
before executing the while statement. Thus, Line #24 should be executed.

[Bug gcov-profile/90023] New: The coverage of a label is incorrect when it is after a return statement and followed by a blank statement

2019-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90023

Bug ID: 90023
   Summary: The coverage of a label is incorrect when it is after
a return statement and followed by a blank statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
#include 

int foo(int a)
{
  void *l = &

  if(a == 4)
; //goto *l;

  return 150;

error:
;//  return a;
}

int main(int argc, char **argv)
{
  printf("value: %d\n", foo(argc));

  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov 
value: 150
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:int foo(int a)
-:4:{
1:5:  void *l = &
-:6:
-:7:  if(a == 4)
-:8:; //goto *l;
-:9:
2:   10:  return 150;
-:   11:
1:   12:error:
-:   13:;//  return a;
-:   14:}
-:   15:
1:   16:int main(int argc, char **argv)
-:   17:{
1:   18:  printf("value: %d\n", foo(argc));
-:   19:
1:   20:  return 0;
-:   21:}

Line #12 is wrongly marked as executed and Line #10 is wrongly marked as
executed twice. 

When, Line #8 and Line #13 are not commented, the coverage is correct as:

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:int foo(int a)
-:4:{
1:5:  void *l = &
-:6:
1:7:  if(a == 4)
#:8:goto *l;
-:9:
1:   10:  return 150;
-:   11:
#:   12:error:
#:   13:  return a;
-:   14:}
-:   15:
1:   16:int main(int argc, char **argv)
-:   17:{
1:   18:  printf("value: %d\n", foo(argc));
-:   19:
1:   20:  return 0;
-:   21:}

[Bug gcov-profile/89675] New: [GCOV] A complex statement in while (1) block is wrongly marked as not-executed in gcov

2019-03-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89675

Bug ID: 89675
   Summary: [GCOV] A complex statement in while (1) block is
wrongly marked as not-executed in gcov
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int foo = 0;
void *bar = 0;
unsigned int baz = 100;

void *pure_alloc ()
{
  void *res;

  while (1)
{
  res = (void *) unsigned int) (foo + bar))) & ~1);
  foo += 2;
  if (foo < baz)
return res;
  ;//foo = 0;
}
}

int main ()
{
  pure_alloc ();
  return 0;
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int foo = 0;
-:2:void *bar = 0;
-:3:unsigned int baz = 100;
-:4:
1:5:void *pure_alloc ()
-:6:{
-:7:  void *res;
-:8:
-:9:  while (1)
-:   10:{
#:   11:  res = (void *) unsigned int) (foo + bar))) & ~1);
1:   12:  foo += 2;
1:   13:  if (foo < baz)
1:   14:return res;
-:   15:  ;//foo = 0;
-:   16:}
-:   17:}
-:   18:
1:   19:int main ()
-:   20:{
1:   21:  pure_alloc ();
1:   22:  return 0;
-:   23:}

Line #11 is wrongly marked as not executed. While Line #15 is not removed, the
coverage result is correct as follows:
$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:88.89% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int foo = 0;
-:2:void *bar = 0;
-:3:unsigned int baz = 100;
-:4:
1:5:void *pure_alloc ()
-:6:{
-:7:  void *res;
-:8:
-:9:  while (1)
-:   10:{
   1*:   11:  res = (void *) unsigned int) (foo + bar))) & ~1);
1:   12:  foo += 2;
1:   13:  if (foo < baz)
1:   14:return res;
#:   15:  foo = 0;
-:   16:}
-:   17:}
-:   18:
1:   19:int main ()
-:   20:{
1:   21:  pure_alloc ();
1:   22:  return 0;
-:   23:}

[Bug gcov-profile/89674] New: [GCOV] A label in if block is not used in reference or goto label is wrongly marked as executed in gcov

2019-03-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89674

Bug ID: 89674
   Summary: [GCOV] A label in if block is not used in reference or
goto label is wrongly marked as executed in gcov
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int main(int argc, char **argv)
{
  int a = 123;

  if (argc == 0)
  {
int *ptr;
label:
  {
   return 0;
  }
  }
  if (argc == 1)
  {
 printf("argc == 1\n");
  }
  return 0;
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
argc == 1
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main(int argc, char **argv)
-:2:{
1:3:  int a = 123;
-:4:
-:5:  if (argc == 0)
-:6:  {
-:7:int *ptr;
1:8:label:
-:9:  {
-:   10:   ;// return 0;
-:   11:  }
-:   12:  }
1:   13:  if (argc == 1)
-:   14:  {
1:   15: printf("argc == 1\n");
-:   16:  }
1:   17:  return 0;
-:   18:}

Line #8 is wrongly marked as executed. When Line #10 is not removed, the result
is correct as follows:
$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
argc == 1
File 'small.c'
Lines executed:75.00% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main(int argc, char **argv)
-:2:{
1:3:  int a = 123;
-:4:
1:5:  if (argc == 0)
-:6:  {
-:7:int *ptr;
#:8:label:
-:9:  {
#:   10:   return 0;
-:   11:  }
-:   12:  }
1:   13:  if (argc == 1)
-:   14:  {
1:   15: printf("argc == 1\n");
-:   16:  }
1:   17:  return 0;
-:   18:}


The test program is a revised version of
gcc-7.4.0/gcc/testsuite/gcc.dg/asan/use-after-scope-goto-2.c

[Bug gcov-profile/89673] New: [GCOV] A label followed with a blank(empty) statement will be wrongly marked as executed in gcov

2019-03-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89673

Bug ID: 89673
   Summary: [GCOV] A label followed with a blank(empty) statement
will be wrongly marked as executed in gcov
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$  gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
struct decision
{
  char enforce_mode;
  struct decision *next;
};


static void clear_modes (p)  register struct decision *p;
{
  goto blah;

foo:
;//  p->enforce_mode = 0;
blah:
  if (p)
goto foo;
}

main()
{
  struct decision *p = 0;
  clear_modes (p);
  exit (0);
}


$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:90.91% of 11
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct decision
-:2:{
-:3:  char enforce_mode;
-:4:  struct decision *next;
-:5:};
-:6:
-:7:
1:8:static void clear_modes (p)  register struct decision *p;
-:9:{
1:   10:  goto blah;
-:   11:
1:   12:foo:
-:   13:;//  p->enforce_mode = 0;
1:   14:blah:
1:   15:  if (p)
#:   16:goto foo;
1:   17:}
-:   18:
1:   19:main()
-:   20:{
1:   21:  struct decision *p = 0;
1:   22:  clear_modes (p);
1:   23:  exit (0);
-:   24:}

Line #12 is wrongly marked as executed. While Line 13 is not removed, the
result is correct as follows:

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

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct decision
-:2:{
-:3:  char enforce_mode;
-:4:  struct decision *next;
-:5:};
-:6:
-:7:
1:8:static void clear_modes (p)  register struct decision *p;
-:9:{
1:   10:  goto blah;
-:   11:
#:   12:foo:
#:   13:  p->enforce_mode = 0;
1:   14:blah:
1:   15:  if (p)
#:   16:goto foo;
1:   17:}
-:   18:
1:   19:main()
-:   20:{
1:   21:  struct decision *p = 0;
1:   22:  clear_modes (p);
1:   23:  exit (0);
-:   24:}

[Bug gcov-profile/89470] New: [GCOV] wrong frequencies when if statement is executed after a complicated "?:"statement

2019-02-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89470

Bug ID: 89470
   Summary: [GCOV] wrong frequencies when if statement is executed
after a complicated "?:"statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int foo()
{
  int hints = 2, xi = 1, dy = 18481, adx = 0, ady = 18481;
  if (dy != 0 && (adx <= ady >> 4))
  {
hints = dy > 0 ? 2 : 1;
if (xi) {
  hints ^= 3;
}
  }
  else
  {
hints = 0;
  }
  return hints;
}

int main()
{
  foo();
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:90.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int foo()
-:2:{
1:3:  int hints = 2, xi = 1, dy = 18481, adx = 0, ady = 18481;
1:4:  if (dy != 0 && (adx <= ady >> 4)) {
   1*:5:hints = dy > 0 ? 2 : 1;
2:6:if (xi) {
1:7:  hints ^= 3;
-:8:}
-:9:  }
-:   10:  else
-:   11:  {
#:   12:hints = 0;
-:   13:  }
1:   14:  return hints;
-:   15:}
-:   16:
1:   17:int main()
-:   18:{
1:   19:  foo();
-:   20:}

Line # 6 is wrongly marked as executed twice which should be only executed
once.

When Line #12 is removed, the result is correst as:
$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int foo()
-:2:{
1:3:  int hints = 2, xi = 1, dy = 18481, adx = 0, ady = 18481;
1:4:  if (dy != 0 && (adx <= ady >> 4)) {
   1*:5:hints = dy > 0 ? 2 : 1;
1:6:if (xi) {
1:7:  hints ^= 3;
-:8:}
-:9:  }
-:   10:  else
-:   11:  {
-:   12:// hints = 0;
-:   13:  }
1:   14:  return hints;
-:   15:}
-:   16:
1:   17:int main()
-:   18:{
1:   19:  foo();
-:   20:}

[Bug gcov-profile/89469] New: [GCOV] wrong frequencies for the first statement in the for(;;) block

2019-02-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89469

Bug ID: 89469
   Summary: [GCOV] wrong frequencies for the first statement in
the for(;;) block
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int main()
{
  int start = 0, mid = 3, limit = 3, lastMid = 6, r = 0;
  for (;;) {
  mid = (start + limit) / 2;
  if (lastMid == mid) {
break;
  }

  r = mid == 1 ? 1 : 0;

  if (r > 0) {
start = mid;
  } else {
return 1;
  }
  }
  return 0;
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:  int start = 0, mid = 3, limit = 3, lastMid = 6, r = 0;
-:4:  for (;;) {
1:5:  mid = (start + limit) / 2;
2:6:  if (lastMid == mid) {
#:7:break;
-:8:  }
-:9:
2:   10:  r = mid == 1 ? 1 : 0;
-:   11:
2:   12:  if (r > 0) {
1:   13:start = mid;
-:   14:  } else {
1:   15:return 1;
-:   16:  }
-:   17:  }
#:   18:  return 0;
-:   19:}

Line #5 is wrongly marked as executed once which should be executed twice. 

When Line #7 is removed, the result is correct as:
$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:  int start = 0, mid = 3, limit = 3, lastMid = 6, r = 0;
-:4:  for (;;) {
2:5:  mid = (start + limit) / 2;
-:6:  if (lastMid == mid) {
-:7:// break;
-:8:  }
-:9:
2:   10:  r = mid == 1 ? 1 : 0;
-:   11:
2:   12:  if (r > 0) {
1:   13:start = mid;
-:   14:  } else {
1:   15:return 1;
-:   16:  }
-:   17:  }
-:   18:  return 0;
-:   19:}

[Bug gcov-profile/89468] New: [GCOV] wrong frequencies when the block is empty in a if statement

2019-02-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89468

Bug ID: 89468
   Summary: [GCOV] wrong frequencies when the block is empty in a
if statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
int main()
{
  int ret = 0;
  int a[2] = {1955, -1957};
  for (int i = 0; i < 2; ++i)
  {
if (i % 2 == 1 && a[i] != -2 * i - 1955) {
  ret = 1;
}
else if (i % 2 == 0 && a[i] != 1955 + 2 * i) {
  // ret = 2;
}
  }
  return ret;
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:  int ret = 0;
1:4:  int a[2] = {1955, -1957};
3:5:  for (int i = 0; i < 2; ++i)
-:6:  {
2:7:if (i % 2 == 1 && a[i] != -2 * i - 1955) {
#:8:  ret = 1;
-:9:}
   1*:   10:else if (i % 2 == 0 && a[i] != 1955 + 2 * i) {
-:   11:  // ret = 2;
-:   12:}
-:   13:  }
1:   14:  return ret;
-:   15:}

Line #10 should be also executed twice as Line #7.

When Line #11 is not removed, the result is correct as:
$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:77.78% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:  int ret = 0;
1:4:  int a[2] = {1955, -1957};
3:5:  for (int i = 0; i < 2; ++i)
-:6:  {
2:7:if (i % 2 == 1 && a[i] != -2 * i - 1955) {
#:8:  ret = 1;
-:9:}
2:   10:else if (i % 2 == 0 && a[i] != 1955 + 2 * i) {
#:   11:  ret = 2;
-:   12:}
-:   13:  }
1:   14:  return ret;
-:   15:}

[Bug gcov-profile/89467] New: [GCOV] wrong freqencies when there is comparison operator in the right side of the assignment statement

2019-02-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89467

Bug ID: 89467
   Summary: [GCOV] wrong freqencies when there is comparison
operator in the right side of the assignment statement
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
void foo(int p)
{
  int e;
  int b = 0, f = 0, d = 0;
  if ((p < f) && p) {
L:
for (e = 0; 0;) ;
  } else if (d) {
b = (0 >= b);
  }

  for (; e <= 3; e++) {
if (b) { continue; }
b = 3;
goto L;
  }
}

void main()
{
  int a = -1;
  foo(a);
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:87.50% of 16
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void foo(int p)
-:2:{
-:3:  int e;
1:4:  int b = 0, f = 0, d = 0;
3:5:  if ((p < f) && p) {
1:6:L:
2:7:for (e = 0; 0;) ;
#:8:  } else if (d) {
#:9:b = (0 >= b);
-:   10:  }
-:   11:
6:   12:  for (; e <= 3; e++) {
5:   13:if (b) { continue; }
1:   14:b = 3;
1:   15:goto L;
-:   16:  }
1:   17:}
-:   18:
1:   19:void main()
-:   20:{
1:   21:  int a = -1;
1:   22:  foo(a);
1:   23:}

Line #5 is wrongly marked as executed 3 times which should be only executed
once. 

When Line #9 is removed, the coverage report will be correct as:

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 14
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void foo(int p)
-:2:{
-:3:  int e;
1:4:  int b = 0, f = 0, d = 0;
1:5:  if ((p < f) && p) {
1:6:L:
2:7:for (e = 0; 0;) ;
-:8:  } else if (d) {
-:9:// b = (0 >= b);
-:   10:  }
-:   11:
6:   12:  for (; e <= 3; e++) {
5:   13:if (b) { continue; }
1:   14:b = 3;
1:   15:goto L;
-:   16:  }
1:   17:}
-:   18:
1:   19:void main()
-:   20:{
1:   21:  int a = -1;
1:   22:  foo(a);
1:   23:}

[Bug gcov-profile/89465] New: [GCOV] Wrong coverage with setjmp and longjmp function

2019-02-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89465

Bug ID: 89465
   Summary: [GCOV] Wrong coverage with setjmp and longjmp function
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
long jmp_buf[5];

void baz(void) { __builtin_longjmp(_buf, 1); }

int main()
{
  int a = 0;
  if (__builtin_setjmp(_buf) == 0) {
while (1) {
  a = 1;
  baz();
}
  }
  return a;
}

$ gcc -O0 --coverage small.c -w; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:85.71% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:long jmp_buf[5];
-:2:
1:3:void baz(void) { __builtin_longjmp(_buf, 1); }
-:4:
1:5:int main()
-:6:{
1:7:  int a = 0;
2:8:  if (__builtin_setjmp(_buf) == 0) {
-:9:while (1) {
#:   10:  a = 1;
1:   11:  baz();
-:   12:}
-:   13:  }
1:   14:  return a;
-:   15:}


Line #10 is wrongly marked as not executed. I am not sure whether this bug has
been fixed in the gcc 8.3.X or gcc 9.0 versions.

[Bug gcov-profile/88913] [GCOV] Wrong frequencies when a global variable is in a while expression in gcov

2019-01-22 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88913

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> Fixed on trunk in r247374.

Thanks.

[Bug gcov-profile/88930] New: [GCOV] Wrong frequences when a if statement is after a ?: statement in gcov

2019-01-20 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88930

Bug ID: 88930
   Summary: [GCOV] Wrong frequences when a if statement is after a
 ?: statement in gcov
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

$ cat small.c
void foo(long dx, long dy, int xi, int yi)
{
  int hints = 0;
  if (dy != 0 && (dx <= 1155)) {
hints = dy > 0 ? 2 : 1;
if (xi) {
  hints = 1;
}
  } else if (dx != 0 && (dy <= 0)) {
hints = 2;
  } else {
hints = 3;
  }
}
void main()
{
  foo(0, 18481, 1, 0);
}

$ gcc --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:76.92% of 13
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void foo(long dx, long dy, int xi, int yi)
-:2:{
1:3:  int hints = 0;
1:4:  if (dy != 0 && (dx <= 1155)) {
   1*:5:hints = dy > 0 ? 2 : 1;
2:6:if (xi) {
1:7:  hints = 1;
-:8:}
#:9:  } else if (dx != 0 && (dy <= 0)) {
#:   10:hints = 2;
-:   11:  } else {
#:   12:hints = 3;
-:   13:  }
1:   14:}
1:   15:void main()
-:   16:{
1:   17:  foo(0, 18481, 1, 0);
1:   18:}

Line #6 is wrongly marked as executed twice. However, the foo  function is call
only once and there is no loop in function foo.

[Bug gcov-profile/88924] New: [GCOV] Wrong frequencies when there is complicated if expressions in gcov

2019-01-19 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88924

Bug ID: 88924
   Summary: [GCOV] Wrong frequencies when there is complicated if
expressions in gcov
   Product: gcc
   Version: 7.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

$ cat small.c
int ca[6] = {244, -245, 244, -246, 245, -246};

void main()
{
  for (int i = 0; i < 6; ++i) {
int flag = i % 2 == 1 && ca[i] != (-2 * i - 1955) >> 3;
if (flag) {
  ;
} else if (i % 2 == 0 && ca[i] != (1955 + 2 * i) >> 3) {
  ;
}
  }

  for (int i = 0; i < 6; ++i) {
if (i % 2 == 1 && ca[i] != (-2 * i - 1955) >> 3) {
  ;
} else if (i % 2 == 0 && ca[i] != (1955 + 2 * i) >> 3) {
  ;
}
  }
}


$ gcc small.c -w --coverage; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int ca[6] = {244, -245, 244, -246, 245, -246};
-:2:
1:3:void main()
-:4:{
7:5:  for (int i = 0; i < 6; ++i) {
6:6:int flag = i % 2 == 1 && ca[i] != (-2 * i - 1955) >> 3;
6:7:if (flag) {
-:8:  ;
6:9:} else if (i % 2 == 0 && ca[i] != (1955 + 2 * i) >> 3) {
-:   10:  ;
-:   11:}
-:   12:  }
-:   13:
7:   14:  for (int i = 0; i < 6; ++i) {
6:   15:if (i % 2 == 1 && ca[i] != (-2 * i - 1955) >> 3) {
-:   16:  ;
3:   17:} else if (i % 2 == 0 && ca[i] != (1955 + 2 * i) >> 3) {
-:   18:  ;
-:   19:}
-:   20:  }
1:   21:}
-:   22:


Line #17 is wrongly marked as executed 3 times. In fact, this line should be
executed 6 times same to Line #9.

[Bug gcov-profile/83599] [GCOV] A If TRUE statement lead the return statement has wrong number of execution in gcov

2019-01-19 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83599

--- Comment #2 from Yibiao Yang  ---
(In reply to Martin Liška from comment #1)
> Thanks for another report, in this case the code is invalid:
> 
>  gcc pr83599.c -Wreturn-type
> pr83599.c: In function ‘func’:
> pr83599.c:7:1: warning: control reaches end of non-void function
> [-Wreturn-type]
>  }
>  ^

Thanks, Martin. Will avoid such kind of invalid bug report.

[Bug gcov-profile/88914] New: [GCOV] Wrong frequencies when unreachable statements within the body of the for loop in gcov

2019-01-18 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88914

Bug ID: 88914
   Summary: [GCOV] Wrong frequencies when unreachable statements
within the body of the for loop in gcov
   Product: gcc
   Version: 7.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

$ cat small.c
int bar(a) { return a*a + 1; }

int main()
{
for (int i = 0; i < 10; i++) {
if (bar(i)) {
continue;
}

if (i == 0) {
abort();
} else {
exit(0);
}
}
}

$ gcc small.c -w --coverage; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:62.50% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
   10:1:int bar(a) { return a*a + 1; }
-:2:
1:3:int main()
-:4:{
   22:5:for (int i = 0; i < 10; i++) {
   10:6:if (bar(i)) {
   10:7:continue;
-:8:}
-:9:
#:   10:if (i == 0) {
#:   11:abort();
-:   12:} else {
#:   13:exit(0);
-:   14:}
-:   15:}
-:   16:}



We can found that Line #5 is wrongly marked as executed much more times. 

When Line #10 to Line #14 are removed. The result is correct.

[Bug gcov-profile/88913] New: [GCOV] Wrong frequencies when a global variable is in a while expression in gcov

2019-01-18 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88913

Bug ID: 88913
   Summary: [GCOV] Wrong frequencies when a global variable is in
a while expression in gcov
   Product: gcc
   Version: 7.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

$ cat small.c
int b;

void main()
{
int c = 0;
while (b) {
c = 1;
}
}

$ gcc small.c --coverage; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int b;
-:2:
1:3:void main()
-:4:{
1:5:int c = 0;
2:6:while (b) {
#:7:c = 1;
-:8:}
1:9:}


We can find that Line #6 is wrongly marked as executed twice.

[Bug target/37845] gcc ignores FP_CONTRACT pragma set to OFF

2019-01-18 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37845

Yibiao Yang  changed:

   What|Removed |Added

 CC||yangyibiao at nju dot edu.cn

--- Comment #7 from Yibiao Yang  ---
Created attachment 45464
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45464=edit
[GCOV] Wrong frequencies when a global variable is in a while expression in
gcov

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)

$ cat small.c
int b;

void main()
{
int c = 0;
while (b) {
c = 1;
}
}

$ gcc small.c --coverage; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int b;
-:2:
1:3:void main()
-:4:{
1:5:int c = 0;
2:6:while (b) {
#:7:c = 1;
-:8:}
1:9:}


We can find that Line #6 is wrongly marked as executed twice.

[Bug gcov-profile/85367] [GCOV] A call to the _subborrow_u64 builtin-function is wrongly marked as executed twice

2018-08-15 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85367

Yibiao Yang  changed:

   What|Removed |Added

 Resolution|INVALID |WORKSFORME

--- Comment #2 from Yibiao Yang  ---
As you mentioned that it works in gcc 8.1.1 while this bug exist in gcc 8.0.0.
Therefore, I change the bug status into worksforme.

[Bug gcov-profile/85201] [GCOV] A statement with two && operators and a comma operator in the for loop body is wrongly marked in gcov

2018-04-23 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85201

--- Comment #2 from Yibiao Yang  ---
@marxin Is this a real bug? or this bug is only default behavior?

[Bug gcov-profile/85377] New: [GCOV] Wrong coverage with label and if(cond) break in while(1)

2018-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85377

Bug ID: 85377
   Summary: [GCOV] Wrong coverage with label and if(cond) break in
while(1)
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc pv
gcc: error: pv: No such file or directory
gcc: fatal error: no input files
compilation terminated.
root@localhost:~/ccv# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int g = 0;

int main ()
{
  while (1)
  {
int i = 2;
L1:
if (g < 1)
  break;
  }

  while (1)
  {
int i = 2;
L2:
// if (g < 1)
  break;
  }
  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:90.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int g = 0;
-:2:
1:3:int main ()
-:4:{
-:5:  while (1)
#:6:  {
1:7:int i = 2;
1:8:L1:
1:9:if (g < 1)
1:   10:  break;
-:   11:  }
-:   12:
-:   13:  while (1)
-:   14:  {
1:   15:int i = 2;
1:   16:L2:
-:   17:// if (g < 1)
1:   18:  break;
-:   19:  }
1:   20:  return 0;
-:   21:}

Line #6 is wrongly marked as not executed with "#".
For the second while statement, coverage of Line #14 is correct.

[Bug gcov-profile/85372] New: [GCOV] Wrong coverage with setjmp and longjmp function

2018-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85372

Bug ID: 85372
   Summary: [GCOV] Wrong coverage with setjmp and longjmp function
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
void *buf[5];

void fjmp (void) {
  __builtin_longjmp (buf, 1);
}

int main(void)
{
  int last = 0;

  if (__builtin_setjmp (buf) == 0) {
__builtin_printf("True  branch\n");
while (1) {
  last = 1;
  fjmp ();
}
  } else {
__builtin_printf("False branch\n");
  }

  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
True  branch
False branch
File 'small.c'
Lines executed:90.00% of 10
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:void *buf[5];
-:2:
1:3:void fjmp (void) {
1:4:  __builtin_longjmp (buf, 1);
-:5:}
-:6:
1:7:int main(void)
-:8:{
1:9:  int last = 0;
-:   10:
2:   11:  if (__builtin_setjmp (buf) == 0) {
1:   12:__builtin_printf("True  branch\n");
-:   13:while (1) {
#:   14:  last = 1;
1:   15:  fjmp ();
-:   16:}
-:   17:  } else {
1:   18:__builtin_printf("False branch\n");
-:   19:  }
-:   20:
1:   21:  return 0;
-:   22:}


Line #14 is wrongly marked as not executed with "#". 
In the first setjmp always return 0, then execute the true branch. Thus, Line
#14 should be executed.

[Bug gcov-profile/85370] New: [GCOV] Wrong coverage with the target_clones attribute

2018-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85370

Bug ID: 85370
   Summary: [GCOV] Wrong coverage with the target_clones attribute
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
__attribute__((target_clones("arch=slm","default")))
int foo1 (int a, int b) {
  return a + b;
}

int foo2 (int a, int b) {
  return a + b;
}

int main() {
  foo1(1, 1);
  foo2(1, 1);
  return 1;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:88.89% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:__attribute__((target_clones("arch=slm","default")))
#:2:int foo1 (int a, int b) {
1:3:  return a + b;
-:4:}
-:5:
1:6:int foo2 (int a, int b) {
1:7:  return a + b;
-:8:}
-:9:
1:   10:int main() {
1:   11:  foo1(1, 1);
1:   12:  foo2(1, 1);
1:   13:  return 1;
1:   14:}


Line #2 is wrongly marked as not executed with "#". 
Function foo2 is with no attribute, the coverage of function foo2 is correct.

[Bug gcov-profile/85367] New: [GCOV] A call to the _subborrow_u64 builtin-function is wrongly marked as executed twice

2018-04-12 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85367

Bug ID: 85367
   Summary: [GCOV] A call to the _subborrow_u64 builtin-function
is wrongly marked as executed twice
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
#include 

int main ()
{
  unsigned char c;
  unsigned long long x, y;

  c = 0;
  x = 1LL;
  y = 0LL;

  /* X = 0x0001, Y = 0x, C = 0.  */
  c = _subborrow_u64 (c, y, x, );

  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

File '/usr/lib/gcc/x86_64-linux-gnu/8/include/adxintrin.h'
Lines executed:100.00% of 1
Creating 'adxintrin.h.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:int main ()
-:4:{
-:5:  unsigned char c;
-:6:  unsigned long long x, y;
-:7:
1:8:  c = 0;
1:9:  x = 1LL;
1:   10:  y = 0LL;
-:   11:
-:   12:  /* X = 0x0001, Y = 0x, C = 0.  */
2:   13:  c = _subborrow_u64 (c, y, x, );
-:   14:
1:   15:  return 0;
-:   16:}


Line #13 is wrongly marked as executed twice. 
Replacing _subborrow_u64 to _subborrow_u32, same problem. 

I am not sure whether the problem is due to the value stored in the address 
will be changed in _subborrow_u64.

[Bug gcov-profile/85351] New: [GCOV] Wrong coverage with an executed exit() in if statement within a called function

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85351

Bug ID: 85351
   Summary: [GCOV] Wrong coverage with an executed exit() in if
statement within a called function
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

/** small.c */
$ cat small.c
#include 

void foo1(int x)
{
  if (x < 1)
exit(0);
}

int main()
{
  foo1(0);
  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:71.43% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:void foo1(int x)
-:4:{
1:5:  if (x < 1)
1:6:exit(0);
#:7:}
-:8:
1:9:int main()
-:   10:{
1:   11:  foo1(0);
#:   12:  return 0;
-:   13:}

*
Line #7 is wrongly marked as "#"
*

/** small2.c */
$ cat small2.c
#include 

void foo1(int x)
{
  // if (x < 1)
exit(0);
}

int main()
{
  foo1(0);
  return 0;
}

$ gcc --coverage small2.c; ./a.out; gcov-8 small2.c; cat small2.c.gcov
File 'small2.c'
Lines executed:80.00% of 5
Creating 'small2.c.gcov'

-:0:Source:small2.c
-:0:Graph:small2.gcno
-:0:Data:small2.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:void foo1(int x)
-:4:{
-:5:  // if (x < 1)
1:6:exit(0);
-:7:}
-:8:
1:9:int main()
-:   10:{
1:   11:  foo1(0);
#:   12:  return 0;
-:   13:}



***
While comparing the coverage of small.c and small2.c, we can find that the
marks of Line #7 in these two files is inconsistant. This confirms that the
coverage of small.c is incorrect.

[Bug gcov-profile/85350] New: [GCOV] wrong coverage when using constant variable in struct declaration

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85350

Bug ID: 85350
   Summary: [GCOV] wrong coverage when using constant variable in
struct declaration
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
#include 

int main (void)
{
  const int t = 2;
  struct s1 {
int x;
int g[t];
  };

  struct s2 {
int x;
int g[2];
  };

  printf("Sucess!\n");
  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
Sucess!
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:int main (void)
-:4:{
1:5:  const int t = 2;
2:6:  struct s1 {
-:7:int x;
1:8:int g[t];
-:9:  };
-:   10:
-:   11:  struct s2 {
-:   12:int x;
-:   13:int g[2];
-:   14:  };
-:   15:
1:   16:  printf("Sucess!\n");
1:   17:  return 0;
-:   18:}


Line #6 is wrongly marked as executed twice. 
The second struct declaration is not using constant variable t. By comparing
these two structs, we can know that constant variable should be the reason that
leads to the incorrect coverage.

[Bug gcov-profile/85349] New: [GCOV] struct varaible definition in while(1) will cause incorrect coverage

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85349

Bug ID: 85349
   Summary: [GCOV] struct varaible definition in while(1) will
cause incorrect coverage
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
struct F {int x;};

int main()
{
  int x = 0;
  while (1) // first while
  {
struct F f1 = {x};
if (f1.x > 0)
  break;
x++;
  }

  x = 0;
  while (1) // second while
  {
if (x > 0)
  break;
x++;
  }

  x = 0;
  while (x < 10) // third while
  {
struct F f2 = {x};
if (f2.x > 0)
  break;
x++;
  }

  x = 0;
  while (x < 10)
  {
if (x > 0)
  break;
x++;
  }
  return 0;
}


$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 23
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct F {int x;};
-:2:
1:3:int main()
-:4:{
1:5:  int x = 0;
-:6:  while (1) // first while
1:7:  {
2:8:struct F f1 = {x};
2:9:if (f1.x > 0)
1:   10:  break;
1:   11:x++;
-:   12:  }
-:   13:
1:   14:  x = 0;
-:   15:  while (1) // second while
-:   16:  {
2:   17:if (x > 0)
1:   18:  break;
1:   19:x++;
-:   20:  }
-:   21:
1:   22:  x = 0;
2:   23:  while (x < 10) // third while
-:   24:  {
2:   25:struct F f2 = {x};
2:   26:if (f2.x > 0)
1:   27:  break;
1:   28:x++;
-:   29:  }
-:   30:
1:   31:  x = 0;
2:   32:  while (x < 10)
-:   33:  {
2:   34:if (x > 0)
1:   35:  break;
1:   36:x++;
-:   37:  }
1:   38:  return 0;
-:   39:}


Line #7 is wrongly marked as "1". 

Line #16 and Line #33 are also the first braces of while statement. While they
are marked as "-". 

By comparing these three while-statements, I think the inconsistency is caused
by the struct variable definition inside the while(1) statement.

[Bug gcov-profile/85338] New: [GCOV] Type conversion leads to incorrect coverage in printf

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85338

Bug ID: 85338
   Summary: [GCOV] Type conversion leads to incorrect coverage in
printf
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
#include 

void Test(long long Val, int Amt)
{
  printf("  lshr: 0x%llx \t\t shl: 0x%llx\n", Val >> Amt, Val << Amt);
  printf("  lshr: 0x%llx\t\tshl: 0x%llx\n",
Val >> Amt, Val << Amt);
  printf("  lshr: 0x%llx \t\t shl: 0x%llx\n",
(unsigned long long)Val >> Amt, Val << Amt);
}

int main()
{
  Test(10, 4);

  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
  lshr: 0x0  shl: 0xa0
  lshr: 0x0 shl: 0xa0
  lshr: 0x0  shl: 0xa0
File 'small.c'
Lines executed:100.00% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:void Test(long long Val, int Amt)
-:4:{
1:5:  printf("  lshr: 0x%llx \t\t shl: 0x%llx\n", Val >> Amt, Val
<< Amt);
1:6:  printf("  lshr: 0x%llx\t\tshl: 0x%llx\n",
-:7:Val >> Amt, Val << Amt);
2:8:  printf("  lshr: 0x%llx \t\t shl: 0x%llx\n",
1:9:(unsigned long long)Val >> Amt, Val << Amt);
1:   10:}
-:   11:
1:   12:int main()
-:   13:{
1:   14:  Test(10, 4);
-:   15:
1:   16:  return 0;
-:   17:}


Line #8 is wrongly marked as executed twice. 
As can be seen from Line #5 and Line #6, I think this incorrect coverage is
caused by type conversions.

[Bug gcov-profile/85337] New: [GCOV] inconsistent coverage in swith-case statement

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85337

Bug ID: 85337
   Summary: [GCOV] inconsistent coverage in swith-case statement
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

cat small.c

#include 

static int func(int i) {
  int a = 0;
  switch (i) {
case 8:
  printf("8\n");
  a = 6;
case 0:
  ;
case 3:
  ;
case 2:
  printf("2\n"); break;
case 1:
  ;
case 7: a = 7;
case 9: printf("9\n"); break;
default: printf("4 or 5 or 6\n"); a = 1;
  }
  return a;
}


int main() {
  int i;
  for (i = 0; i < 10; ++i)
func(i);
  return 0;
}
root@localhost:~/ccv# gcc --coverage small.c; ./a.out; gcov-8 small.c; cat
small.c.gcov
2
9
2
2
4 or 5 or 6
4 or 5 or 6
4 or 5 or 6
9
8
2
9
File 'small.c'
Lines executed:100.00% of 17
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:
-:2:#include 
-:3:
   10:4:static int func(int i) {
   10:5:  int a = 0;
   10:6:  switch (i) {
1:7:case 8:
1:8:  printf("8\n");
1:9:  a = 6;
4:   10:case 0:
-:   11:  ;
-:   12:case 3:
-:   13:  ;
-:   14:case 2:
4:   15:  printf("2\n"); break;
2:   16:case 1:
-:   17:  ;
2:   18:case 7: a = 7;
3:   19:case 9: printf("9\n"); break;
3:   20:default: printf("4 or 5 or 6\n"); a = 1;
-:   21:  }
   10:   22:  return a;
-:   23:}
-:   24:
-:   25:
1:   26:int main() {
-:   27:  int i;
   11:   28:  for (i = 0; i < 10; ++i)
   10:   29:func(i);
1:   30:  return 0;
-:   31:}

Line #10, Line #12, Line #14 are respectively marked as "4", "-", "-". 
I am not claim that this is a bug since I am not sure whether it is the default
behavior of gcov.

[Bug gcov-profile/85336] [GCOV] wrong coverage for builtin functions and "||" logic operators in return statement

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85336

--- Comment #1 from Yibiao Yang  ---
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

[Bug gcov-profile/85336] New: [GCOV] wrong coverage for builtin functions and "||" logic operators in return statement

2018-04-11 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85336

Bug ID: 85336
   Summary: [GCOV] wrong coverage for builtin functions and "||"
logic operators in return statement
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
#include 

static int special_format (const char *fmt)
{
  return (
strchr (fmt, '*') != 0 ||
strchr (fmt, 'V') != 0 ||
strchr (fmt, 'S') != 0 ||
strchr (fmt, 'n') != 0 );
}

int main()
{
  special_format ("ee");
  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
1:3:static int special_format (const char *fmt)
-:4:{
-:5:  return (
2:6:strchr (fmt, '*') != 0 ||
1:7:strchr (fmt, 'V') != 0 ||
3:8:strchr (fmt, 'S') != 0 ||
1:9:strchr (fmt, 'n') != 0 );
-:   10:}
-:   11:
1:   12:int main()
-:   13:{
1:   14:  special_format ("ee");
1:   15:  return 0;
-:   16:}


Line #6, #7, #8, #9 are wrongly marked with different different execution times
in a single return statement.

[Bug gcov-profile/85333] New: [GCOV] Builtin function is wrongly marked as "-" in gcov

2018-04-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85333

Bug ID: 85333
   Summary: [GCOV] Builtin function is wrongly marked as "-" in
gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

gcc -v && gcov-8 -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)
gcov (Ubuntu 8-20170923-1ubuntu2) 8.0.0 20170923 (experimental) [trunk revision
253118]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.


$ cat small.c
#include 
#include 

int f(int a, int b)
{
  return a+b;
}

int main()
{
  f(1, 2);
  strcmp("a","ab");
  return 0;
}

$ gcc --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:#include 
-:3:
1:4:int f(int a, int b)
-:5:{
1:6:  return a+b;
-:7:}
-:8:
1:9:int main()
-:   10:{
1:   11:  f(1, 2);
-:   12:  strcmp("a","ab");
1:   13:  return 0;
-:   14:}

**
Line #12 is marked as "-". Line #11 is also a call statement. 
I am not sure whether this is the default behaivor for builtin functions.

[Bug gcov-profile/85332] New: [GCOV] wrong coverage with do-while in swith-case statement

2018-04-10 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85332

Bug ID: 85332
   Summary: [GCOV] wrong coverage with do-while in swith-case
statement
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.2.0-8ubuntu3'
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3)

$ cat small.c
int doit(int sel, int n, void *p)
{
  int * const p0 = p;

  switch (sel)
  {
case 0:
  do {*p0 += *p0;} while (--n);
  return *p0 == 0;

default:
  abort ();
  }
}

int main()
{
  int v0;
  v0 = 1; doit(0, 3, );
  exit (0);
}


$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:81.82% of 11
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int doit(int sel, int n, void *p)
-:2:{
1:3:  int * const p0 = p;
-:4:
1:5:  switch (sel)
-:6:  {
2:7:case 0:
3:8:  do {*p0 += *p0;} while (--n);
1:9:  return *p0 == 0;
-:   10:
#:   11:default:
#:   12:  abort ();
-:   13:  }
-:   14:}
-:   15:
1:   16:int main()
-:   17:{
-:   18:  int v0;
1:   19:  v0 = 1; doit(0, 3, );
1:   20:  exit (0);
-:   21:}

***
Line #7 is wrongly marked as executed twice.

[Bug gcov-profile/85299] [GCOV] In for(;;), a "if(0) break;" statement is wrongly marked as executed when it is prefixed with an array declaration "int a[1];" and followed by "if(0) continue; break;"

2018-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85299

--- Comment #1 from Yibiao Yang  ---
Bug 85202 is another most similar bug with the "continue" statement. 

From my point of view, they should be different bugs. 

Here is the copy of Bug 85202:

$ cat small.c
void main() {
  int i = 0;
  for (; i < 1; i++) {
int b = 0;

if (0)
  continue;
if (1)
  continue;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main() {
1:2:  int i = 0;
2:3:  for (; i < 1; i++) {
1:4:int b = 0;
-:5:
-:6:if (0)
1:7:  continue;
-:8:if (1)
1:9:  continue;
-:   10:  }
1:   11:}

Line #7 is wrongly marked as executed.

[Bug gcov-profile/85299] New: [GCOV] "if(0) break;" is wrongly marked as executed when it is prefixed with an array declaration "int a[1];" and followed by "if(0) continue; break;" in gcov

2018-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85299

Bug ID: 85299
   Summary: [GCOV] "if(0) break;" is wrongly marked as executed
when it is prefixed with an array declaration "int
a[1];" and followed by "if(0) continue; break;" in
gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
      Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc pv
gcc: error: pv: No such file or directory
gcc: fatal error: no input files
compilation terminated.
root@localhost:~/ccv# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
void main() {
  for (;;) {
int a[1];
if (0)
  break;
if (0)
  continue;
break;
  }
}


$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main() {
-:2:  for (;;) {
-:3:int a[1];
-:4:if (0)
1:5:  break;
-:6:if (0)
-:7:  continue;
1:8:break;
-:9:  }
1:   10:}


Line #5 is wrongly marked as executed.

When we replacing Line #7 "if(0) continue;" with "if(0) break;", the result is
correct.

[Bug gcov-profile/85297] New: [GCOV] "if(0) return;" is wrongly marked as executed when it is prefixed with a address operator "int c=0; " and followed by "if(1) return;" in gcov

2018-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85297

Bug ID: 85297
   Summary: [GCOV] "if(0) return;" is wrongly marked as executed
when it is prefixed with a address operator "int c=0;
" and followed by "if(1) return;" in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
      Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int main()
{
int c = 0;

if(0)
return 0;
if(1)
return 1;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat smal.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:int c = 0;
-:4:
-:5:if(0)
1:6:return 0;
-:7:if(1)
1:8:return 1;
-:9:}


Line #6 is wrongly marked as executed.

[Bug gcov-profile/85294] [GCOV] A "if(0) break;" statement is wrongly marked as executed when they are nested in for(;;) statement and prefixed with an struct declaration and followed by "if(1) break

2018-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85294

--- Comment #1 from Yibiao Yang  ---
1. when removing Line #7 and Line #8, the result is correct. 
2. when removing Line #4, the result is also correct. 


Besides, there is an existing bug 85274 is similar to the current bug. Bug
85274 is copyed as follows. It is unclear whether this one is a duplication of
bug 85274.  

$ cat small.c
struct s {int s1;};
int a = 0;
int main() {
  for (; 1;) {
struct s g;
if (0)
  return 2;
return 0;
a = 0;
  }
  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat smal.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct s {int s1;};
-:2:int a = 0;
1:3:int main() {
1:4:  for (; 1;) {
-:5:struct s g;
-:6:if (0)
1:7:  return 2;
1:8:return 0;
-:9:a = 0;
-:   10:  }
#:   11:  return 0;
-:   12:}

**
Line #7 is wrongly marked as executed.

[Bug gcov-profile/85294] New: [GCOV] A "if(0) break;" statement is wrongly marked as executed when they are nested in for(;;) statement and prefixed with an struct declaration and followed by "if(1)

2018-04-09 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85294

Bug ID: 85294
   Summary: [GCOV]  A "if(0) break;" statement is wrongly marked
as executed when they are nested in for(;;) statement
and prefixed with an struct declaration and followed
by "if(1) break;" statement in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
struct s {int a;};
void main() {
  for (;;) {
struct s s1;
if (0)
  break;
if (1)
  break;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct s {int a;};
1:2:void main() {
-:3:  for (;;) {
-:4:struct s s1;
-:5:if (0)
1:6:  break;
-:7:if (1)
1:8:  break;
-:9:  }
1:   10:}


Line #6 is wrongly marked as executed.

[Bug gcov-profile/85276] [GCOV] A comparative statement with '=', '&&' , '||', and '==' operators is wrongly marked as executed twice in gcov

2018-04-07 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85276

--- Comment #1 from Yibiao Yang  ---
This bug is similar to bug 85163.

As it is not a call statement apart from bug 85163, I report it as a new one.

[Bug gcov-profile/85276] New: [GCOV] A comparative statement with '=', '&&' , '||', and '==' operators is wrongly marked as executed twice in gcov

2018-04-07 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85276

Bug ID: 85276
   Summary: [GCOV] A comparative statement with '=', '&&' , '||',
and '==' operators is wrongly marked as executed twice
in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int a, b, c, d, e;
void main() {
  ((e=a) && c || 5 || 0) == b || d;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 3
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a, b, c, d, e;
1:2:void main() {
2:3:  ((e=a) && c || 5 || 0) == b || d;
1:4:}


**
Line #3 is wrongly marked as executed twice.

[Bug gcov-profile/85274] New: [GCOV] A return statement in if(0) block is wrongly marked as executed when they are nested in for(;1;) statement and prefixed with an struct declaration and followed by

2018-04-07 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85274

Bug ID: 85274
   Summary: [GCOV] A return statement in if(0) block is wrongly
marked as executed when they are nested in for(;1;)
statement and prefixed with an struct declaration and
followed by a assignment statement in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
struct s {int s1;};
int a = 0;
int main() {
  for (; 1;) {
struct s g;
if (0)
  return 2;
return 0;
a = 0;
  }
  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat smal.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:struct s {int s1;};
-:2:int a = 0;
1:3:int main() {
1:4:  for (; 1;) {
-:5:struct s g;
-:6:if (0)
1:7:  return 2;
1:8:return 0;
-:9:a = 0;
-:   10:  }
#:   11:  return 0;
-:   12:}

**
Line #7 is wrongly marked as executed. 
while removing any of Line #5 or Line #9, the result is correct.

[Bug gcov-profile/85273] New: [GCOV] return statement in else block of if(1) statement when there is an array declaration statement and a goto statement in gcov

2018-04-07 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85273

Bug ID: 85273
   Summary: [GCOV] return statement in else block of if(1)
statement when there is an array declaration statement
and a goto statement in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
int main() {
b:
  {
int c[1];
if (1)
  ;
else
  return 0;
return 0;
goto b;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main() {
1:2:b:
-:3:  {
-:4:int c[1];
-:5:if (1)
-:6:  ;
-:7:else
1:8:  return 0;
1:9:return 0;
-:   10:goto b;
-:   11:  }
-:   12:}

**
Line #8 is wrongly marked as executed.

While removing any of Line #4 or Line #10, the result is correct.

[Bug gcov-profile/85272] [GCOV] return statement in the else block of if(1) statement nested in a for(;;) statement is wrongly marked as executed in gcov

2018-04-06 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85272

--- Comment #1 from Yibiao Yang  ---
when we replace Line #6 from "continue;" to ";" or remove Line #3 "int e[1];",
the result is correct.

[Bug gcov-profile/85272] New: [GCOV] return statement in the else block of if(1) statement nested in a for(;;) statement is wrongly marked as executed in gcov

2018-04-06 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85272

Bug ID: 85272
   Summary: [GCOV] return statement in the else block of if(1)
statement nested in a for(;;) statement is wrongly
marked as executed in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int main() {
  for (;;) {
int e[1];
if (1) {
  if (0)
continue;
} else
  return 0;
return 1;
  }
  return 2;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 3
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main() {
-:2:  for (;;) {
-:3:int e[1];
-:4:if (1) {
-:5:  if (0)
-:6:continue;
-:7:} else
1:8:  return 0;
1:9:return 1;
-:   10:  }
-:   11:  return 2;
-:   12:}


*
Line #8 is wrongly marked as executed.

[Bug gcov-profile/85245] [GCOV] A return statement in the if(0) block is wrongly marked as executed when they are nested in the true block of if (cond-expression) statement in gcov

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85245

--- Comment #1 from Yibiao Yang  ---
(In reply to Yibiao Yang from comment #0)
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
> --enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
> --with-gcc-major-version-only --program-suffix=-8
> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
> --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
> --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes
> --with-default-libstdcxx-abi=new --enable-gnu-unique-object
> --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
> --with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
> --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
> --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
> --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
> 8-20170923-1ubuntu2)
> 
> 
> $ cat small.c
> int a=0;
> int main() {
>   {
> int c[1];
> if (a < 1) {
>   if (0)
> return 0;
>   return 1;
> }

same bug
for(;a<1;) {
  if(0)
return 0;
  return 1;
}
 "return 0;" will also be marked as executed 
***

>   }
>   return 0;
> }
> 
> $ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
> File 'small.c'
> Lines executed:80.00% of 5
> Creating 'small.c.gcov'
> 
> -:0:Source:small.c
> -:0:Graph:small.gcno
> -:0:Data:small.gcda
> -:0:Runs:1
> -:0:Programs:1
> -:1:int a=0;
> 1:2:int main() {
> -:3:  {
> -:4:int c[1];
> 1:5:if (a < 1) {
> -:6:  if (0)
> 1:7:return 0;
> 1:8:  return 1;
> -:9:}
> -:   10:  }
> #:   11:  return 0;
> -:   12:}
> 
> 
> Line #7 is wrongly marked as executed.

[Bug gcov-profile/85245] New: [GCOV] A return statement in the if(0) block is wrongly marked as executed when they are nested in the true block of if (cond-expression) statement in gcov

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85245

Bug ID: 85245
   Summary: [GCOV] A return statement in the if(0) block is
wrongly marked as executed when they are nested in the
true block of if (cond-expression) statement in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)


$ cat small.c
int a=0;
int main() {
  {
int c[1];
if (a < 1) {
  if (0)
return 0;
  return 1;
}
  }
  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a=0;
1:2:int main() {
-:3:  {
-:4:int c[1];
1:5:if (a < 1) {
-:6:  if (0)
1:7:return 0;
1:8:  return 1;
-:9:}
-:   10:  }
#:   11:  return 0;
-:   12:}


Line #7 is wrongly marked as executed.

[Bug gcov-profile/85243] [GCOV] A return statement in the if(0) block is wrongly marked as executed when prefixed with an array declaration statement and followed by a "for(;cond-expression;) return;

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85243

--- Comment #1 from Yibiao Yang  ---
When:

1. removing Line #3 and Line #9, i.e., the { } block
or 
2. changing "for(;a<2;)" to "for(;1;)" 
or
3. removing Line #4

the result are both  correct.

[Bug gcov-profile/85243] New: [GCOV] A return statement in the if(0) block is wrongly marked as executed when prefixed with an array declaration statement and followed by a "for(;cond-expression;) ret

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85243

Bug ID: 85243
   Summary: [GCOV] A return statement in the if(0) block is
wrongly marked as executed when prefixed with an array
declaration statement and followed by a
"for(;cond-expression;) return; " statement when they
are in a dependent block in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int a=0;
int main() {
  {
int d[1];
if (0)
  return 0;
for (; a<2;)
  return 1;
  }
  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:80.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a=0;
1:2:int main() {
-:3:  {
-:4:int d[1];
-:5:if (0)
1:6:  return 0;
1:7:for (; a<2;)
1:8:  return 1;
-:9:  }
#:   10:  return 0;
-:   11:}


**
Line #6 is wrongly marked as executed.

[Bug gcov-profile/85225] [GCOV] An array reference in the for(;;) loop will lead the loop be marked as wrong execution times in gcov

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85225

--- Comment #1 from Yibiao Yang  ---
$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)


***
Is this because the first loop of for(;;) statement is optimized out? 


Besides, in my experience of testing the gcov, the for(;;), for(;1;), if(1),
and if(0) statements produced a lots of different problems. 

I was wondering whether it is becuase the code optimization of compilers that
lead to the incorrect behavior of gcov.

[Bug gcov-profile/85225] New: [GCOV] An array reference in the for(;;) loop will lead the loop be marked as wrong execution times in gcov

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85225

Bug ID: 85225
   Summary: [GCOV] An array reference in the for(;;) loop will
lead the loop be marked as wrong execution times in
gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
void main() {
  int a = 1;
  for (;;) {
int b[1] = {0};
b[0];
if (a) {
  a = 0;
} else
  break;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 8
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main() {
1:2:  int a = 1;
1:3:  for (;;) {
2:4:int b[1] = {0};
-:5:b[0];
2:6:if (a) {
1:7:  a = 0;
-:8:} else
1:9:  break;
-:   10:  }
1:   11:}


Line #3 is marked as executed once. In fact, it should have executed twice.

[Bug gcov-profile/85201] [GCOV] A statement with two && operators and a comma operator in the for loop body is wrongly marked in gcov

2018-04-05 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85201

--- Comment #1 from Yibiao Yang  ---
(In reply to Yibiao Yang from comment #0)
> $ gcc -v 
> gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
> --enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
> --with-gcc-major-version-only --program-suffix=-8
> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
> --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
> --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes
> --with-default-libstdcxx-abi=new --enable-gnu-unique-object
> --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
> --with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
> --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
> --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
> --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
> 8-20170923-1ubuntu2)
> 
> $ cat small.c
> void main() {
>   int a = 0;
>   int b = 0;
>   int c = 0;
>   for (; a >= 0; a--) {
> (c && b, 1) && b;
>   }
> }
> 
> $ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
> File 'small.c'
> Lines executed:100.00% of 7
> Creating 'small.c.gcov'
> 
> -:0:Source:small.c
> -:0:Graph:small.gcno
> -:0:Data:small.gcda
> -:0:Runs:1
> -:0:Programs:1
> 1:1:void main() {
> 1:2:  int a = 0;
> 1:3:  int b = 0;
> 1:4:  int c = 0;
> 2:5:  for (; a >= 0; a--) {
> 2:6:(c && b, 1) && b;

I am not sure this is a duplication of bug 85163. When changing the operators
in the code of bug 85163, the result is correct. While  changing '&&' to '||'
of the code here, the problem is still exist. 

> -:7:  }
> 1:8:}
> 
> 
> Line #6 is wrongly marked as executed twice.

[Bug gcov-profile/85219] New: [GCOV] A "if(1) continue;" statement in a the else block of "if(0)" statement is wrongly marked as executed when surrounded by array delaration statement and break/contin

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85219

Bug ID: 85219
   Summary: [GCOV] A "if(1) continue;" statement in a the else
block of "if(0)" statement is wrongly marked as
executed when surrounded by array delaration statement
and break/continue statement in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)


$ cat small.c
void  main ()
{
int a = 0;
for (; a < 1; a++) {
int b[1];
if ( 1 )
;
else {
if (1)
continue;
break;
}
continue;
}
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void  main ()
-:2:{
1:3:int a = 0;
2:4:for (; a < 1; a++) {
-:5:int b[1];
-:6:if ( 1 )
-:7:;
-:8:else {
-:9:if (1)
1:   10:continue;
-:   11:break;
-:   12:}
1:   13:continue;
-:   14:}
1:   15:}



**
Line #10 is wrongly marked as executed here. 
While remoing any of the statement in Line #11 or Line #13 or Line #5, the
result is correct. 
**

[Bug gcov-profile/85199] [GCOV] A cond-expr with a iterative variable in a for loop is marked as "-" in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85199

--- Comment #1 from Yibiao Yang  ---
(In reply to Yibiao Yang from comment #0)
> $ gcc -v 
> gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
> OFFLOAD_TARGET_NAMES=nvptx-none
> OFFLOAD_TARGET_DEFAULT=1
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu
> 8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
> --enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
> --with-gcc-major-version-only --program-suffix=-8
> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
> --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
> --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes
> --with-default-libstdcxx-abi=new --enable-gnu-unique-object
> --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
> --with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
> --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
> --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
> --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
> 8-20170923-1ubuntu2)
> 
> $ cat small.c
> void main()
> {
> int b = 0;
> for(;
> b < 1;
> b++) {
> ;
> }
> }
> 
> $ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
> File 'small.c'
> Lines executed:100.00% of 5
> Creating 'small.c.gcov'
> 
> -:0:Source:small.c
> -:0:Graph:small.gcno
> -:0:Data:small.gcda
> -:0:Runs:1
> -:0:Programs:1
> 1:1:void main()
> -:2:{
> 1:3:int b = 0;
> 2:4:for(;
> -:5:b < 1;
> 1:6:b++) {
> -:7:;
> -:8:}
> 1:9:}
> 
> Here, we can see that Line #4 is marked as executed twice and Line #5 "b <
> 1;" is marked as "-".
> 

I was wondering that this is the default behavior of gcov.

[Bug gcov-profile/85218] New: [GCOV] A return statement in the if(0) block is wrongly marked as executed when there is an array index and an {array declare statement} around it in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85218

Bug ID: 85218
   Summary: [GCOV] A return statement in the if(0) block is
wrongly marked as executed when there is an array
index and an {array declare statement} around it in
gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int main()
{
int b[1] = {0};
b[0];
if (0)
return 0;
return 1;

{
int c[1];
}
}


$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat sall.c.gcov
File 'small.c'
Lines executed:100.00% of 4
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int main()
-:2:{
1:3:int b[1] = {0};
-:4:b[0];
-:5:if (0)
1:6:return 0;
1:7:return 1;
-:8:
-:9:{
-:   10:int c[1];
-:   11:}
-:   12:}


**
Line #6 is wrongly marked as executed. 

The result is correct while removing the following lines:
Line 9 and Line 11 (the braces) are removed
or
Line #4 is removed.

[Bug gcov-profile/85217] [GCOV] A no side effect statement between a break statement and a continue statement will lead to incorrect code coverage in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85217

--- Comment #1 from Yibiao Yang  ---
$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

In addition, the result is also correct when Line #5 is removed.

[Bug gcov-profile/85217] New: [GCOV] A no side effect statement between a break statement and a continue statement will lead to incorrect code coverage in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85217

Bug ID: 85217
   Summary: [GCOV] A no side effect statement between a break
statement and a continue statement will lead to
incorrect code coverage in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
int a=0;

void main() {
  for (;; a++) {
int c[1];
if (a) {
  break;
  a;
  continue;
}
continue;
  }
}


$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a=0;
-:2:
2:3:void main() {
1:4:  for (;; a++) {
-:5:int c[1];
2:6:if (a) {
1:7:  break;
-:8:  a;
1:9:  continue;
-:   10:}
1:   11:continue;
-:   12:  }
1:   13:}

Line #9 is wrongly marked as executed. While Line #8 or Line #11 is removed,
the result is correct.

[Bug gcov-profile/85206] [GCOV] a return statement in the body of for(;0;) loop is wrongly marked as executed in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85206

--- Comment #1 from Yibiao Yang  ---
The code of this bug is with different code structure of bug 85188, such that I
reported these two bugs respectively.

[Bug gcov-profile/85206] New: [GCOV] a return statement in the body of for(;0;) loop is wrongly marked as executed in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85206

Bug ID: 85206
   Summary: [GCOV] a return statement in the body of for(;0;) loop
is wrongly marked as executed in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int a = 1;
int main() {
  if (1) {
int e[1];
for (; a>0;) {
  for (; 0;)
return 2;
  return 1;
}
  }
  return 0;
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:83.33% of 6
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a = 1;
1:2:int main() {
-:3:  if (1) {
-:4:int e[1];
1:5:for (; a>0;) {
1:6:  for (; 0;)
1:7:return 2;
1:8:  return 1;
-:9:}
-:   10:  }
#:   11:  return 0;
-:   12:}


Line #7 is wrongly marked as executed. However, it should be not executed since
it is in the for(;0;) body.

[Bug gcov-profile/85202] New: [GCOV] A continue statement in the body of the if(0) statement by following a if(1) statement will lead to incorrect code coverage in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85202

Bug ID: 85202
   Summary: [GCOV] A continue statement in the body of the if(0)
statement by following a if(1) statement will lead to
incorrect code coverage in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
void main() {
  int i = 0;
  for (; i < 1; i++) {
int b = 0;

if (0)
  continue;
if (1)
  continue;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main() {
1:2:  int i = 0;
2:3:  for (; i < 1; i++) {
1:4:int b = 0;
-:5:
-:6:if (0)
1:7:  continue;
-:8:if (1)
1:9:  continue;
-:   10:  }
1:   11:}

Line #7 is wrongly marked as executed. 
when we removed Line 8 and Line 9 or when we removed Line #5, the result is
correct.

[Bug gcov-profile/85201] New: [GCOV] A statement with two && operators and a comma operator in the for loop body is wrongly marked in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85201

Bug ID: 85201
   Summary: [GCOV] A statement with two && operators and a comma
operator in the for loop body is wrongly marked in
gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
void main() {
  int a = 0;
  int b = 0;
  int c = 0;
  for (; a >= 0; a--) {
(c && b, 1) && b;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 7
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main() {
1:2:  int a = 0;
1:3:  int b = 0;
1:4:  int c = 0;
2:5:  for (; a >= 0; a--) {
2:6:(c && b, 1) && b;
-:7:  }
1:8:}


Line #6 is wrongly marked as executed twice.

[Bug gcov-profile/85199] New: [GCOV] A cond-expr with a iterative variable in a for loop is marked as "-" in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85199

Bug ID: 85199
   Summary: [GCOV] A cond-expr with a iterative variable in a for
loop is marked as "-" in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
void main()
{
int b = 0;
for(;
b < 1;
b++) {
;
}
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:void main()
-:2:{
1:3:int b = 0;
2:4:for(;
-:5:b < 1;
1:6:b++) {
-:7:;
-:8:}
1:9:}

Here, we can see that Line #4 is marked as executed twice and Line #5 "b < 1;"
is marked as "-".

I was wondering whether this is a bug. 

Since b is changed in each loop, such that "b < 1" should not be optimized out.
Therefore, I think the correct mark should be as follows: 
Line #4 is marked as executed once and Line #5 is marked as executed twice.

[Bug gcov-profile/85197] New: [GCOV] The main function is wrongly marked as executed twice in gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85197

Bug ID: 85197
   Summary: [GCOV] The main function is wrongly marked as executed
twice in gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int a = 0;
int *b = 
void main() {
  while(1) {
if (a)
  break;
a++;
  }
}

$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:100.00% of 5
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
-:1:int a = 0;
-:2:int *b = 
2:3:void main() {
-:4:  while(1) {
2:5:if (a)
1:6:  break;
1:7:a++;
-:8:  }
1:9:}


Line #3 (the main function) is wrongly marked as executed twice. It should be
executed once.

[Bug gcov-profile/85188] [GCOV] a int arrary and a goto statement around the for(;0;) statement will lead to incoccrect code coverage in Gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85188

--- Comment #1 from Yibiao Yang  ---
*** Bug 85187 has been marked as a duplicate of this bug. ***

[Bug gcov-profile/85187] [GCOV] [GCOV] and a int arrary before the for(;0;) statement and goto statement in its body is wrongly marked as not executed when there is a int array in its body in Gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85187

Yibiao Yang  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Yibiao Yang  ---
sorry for the duplicate report

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

[Bug gcov-profile/85188] New: [GCOV] a int arrary and a goto statement around the for(;0;) statement will lead to incoccrect code coverage in Gcov

2018-04-04 Thread yangyibiao at nju dot edu.cn
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85188

Bug ID: 85188
   Summary: [GCOV]  a int arrary and a goto statement around the
for(;0;) statement will lead to incoccrect code
coverage in Gcov
   Product: gcc
   Version: 8.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: yangyibiao at nju dot edu.cn
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ gcc -v 
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
8-20170923-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,c++,go,brig,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.0.0 20170923 (experimental) [trunk revision 253118] (Ubuntu
8-20170923-1ubuntu2)

$ cat small.c
int *c() {
  int b = 1;
f:
  if (b) {
short g[1];
for (; 0;) {
  goto f;
  return 0;
}
return 0;
  } else
;
  return 0;
}
void main() { c(); }


$ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov
File 'small.c'
Lines executed:88.89% of 9
Creating 'small.c.gcov'

-:0:Source:small.c
-:0:Graph:small.gcno
-:0:Data:small.gcda
-:0:Runs:1
-:0:Programs:1
1:1:int *c() {
1:2:  int b = 1;
1:3:f:
1:4:  if (b) {
-:5:short g[1];
1:6:for (; 0;) {
-:7:  goto f;
1:8:  return 0;
-:9:}
1:   10:return 0;
-:   11:  } else
-:   12:;
#:   13:  return 0;
-:   14:}
1:   15:void main() { c(); }

Line #8 is wrongly marked as executed.

  1   2   >