public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements
@ 2022-06-26 15:06 njuwy at smail dot nju.edu.cn
2022-06-27 13:45 ` [Bug gcov-profile/106090] " marxin at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2022-06-26 15:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
Bug ID: 106090
Summary: [GCOV] Wrong coverage for loop statements
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: njuwy at smail dot nju.edu.cn
CC: marxin at gcc dot gnu.org
Target Milestone: ---
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:volatile int cnt = 0;
-: 2:
-: 3:__attribute__((noinline, noclone)) static int
5: 4:last (void)
-: 5:{
5: 6: return ++cnt % 5 == 0;
-: 7:}
-: 8:
-: 9:__attribute__((noinline, noclone)) static void
6: 10:do_it (void)
-: 11:{
6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
6: 13:}
-: 14:
1: 15:static void f1 (void)
-: 16:{
1: 17: do_it();
4: 18: for (;; do_it())
-: 19: {
5: 20: if (last ())
1: 21: break;
-: 22: }
1: 23: do_it ();
1: 24:}
-: 25:
-: 26:int
1: 27:main ()
-: 28:{
1: 29: f1 ();
-: 30:}
Should the coverage of line 18 be 5?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
@ 2022-06-27 13:45 ` marxin at gcc dot gnu.org
2022-07-03 3:19 ` njuwy at smail dot nju.edu.cn
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-27 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
No, it's correct as it only contains do_it() call that is triggered the same
number times as line 20 minus one.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
2022-06-27 13:45 ` [Bug gcov-profile/106090] " marxin at gcc dot gnu.org
@ 2022-07-03 3:19 ` njuwy at smail dot nju.edu.cn
2022-07-03 3:23 ` njuwy at smail dot nju.edu.cn
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2022-07-03 3:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
--- Comment #2 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
(In reply to Martin Liška from comment #1)
> No, it's correct as it only contains do_it() call that is triggered the same
> number times as line 20 minus one.
(In reply to Martin Liška from comment #1)
> No, it's correct as it only contains do_it() call that is triggered the same
> number times as line 20 minus one.
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:volatile int cnt = 0;
-: 2:
-: 3:__attribute__((noinline, noclone)) static int
5: 4:last (void)
-: 5:{
5: 6: return ++cnt % 5 == 0;
-: 7:}
-: 8:
-: 9:__attribute__((noinline, noclone)) static void
6: 10:do_it (void)
-: 11:{
6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
6: 13:}
-: 14:
1: 15:static void f1 (void)
-: 16:{
1: 17: do_it();
4: 18: for (; 0<1; do_it())
-: 19: {
5: 20: if (last ())
1: 21: break;
-: 22: }
1: 23: do_it ();
1: 24:}
-: 25:
-: 26:int
1: 27:main ()
-: 28:{
1: 29: f1 ();
-: 30:}
do_it() is indeed called 4 times,but I wonder how the coverage statistiscs of
the for-statement is calculated. It doesn't become 5 untill the for-stamentment
is completed.
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:volatile int cnt = 0;
-: 2:
-: 3:__attribute__((noinline, noclone)) static int
5: 4:last (void)
-: 5:{
5: 6: return ++cnt % 5 == 0;
-: 7:}
-: 8:
-: 9:__attribute__((noinline, noclone)) static void
6: 10:do_it (void)
-: 11:{
6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
6: 13:}
-: 14:
1: 15:static void f1 (void)
-: 16:{
1: 17: do_it();
5: 18: for (int a=0;0<1;do_it())
-: 19: {
5: 20: if (last ())
1: 21: break;
-: 22: }
1: 23: do_it ();
1: 24:}
-: 25:
-: 26:int
1: 27:main ()
-: 28:{
1: 29: f1 ();
-: 30:}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
2022-06-27 13:45 ` [Bug gcov-profile/106090] " marxin at gcc dot gnu.org
2022-07-03 3:19 ` njuwy at smail dot nju.edu.cn
@ 2022-07-03 3:23 ` njuwy at smail dot nju.edu.cn
2022-07-04 11:36 ` marxin at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2022-07-03 3:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
--- Comment #3 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
(In reply to Yang Wang from comment #2)
> (In reply to Martin Liška from comment #1)
> > No, it's correct as it only contains do_it() call that is triggered the same
> > number times as line 20 minus one.
>
> (In reply to Martin Liška from comment #1)
> > No, it's correct as it only contains do_it() call that is triggered the same
> > number times as line 20 minus one.
>
> -: 0:Source:test.c
> -: 0:Graph:test.gcno
> -: 0:Data:test.gcda
> -: 0:Runs:1
> -: 1:volatile int cnt = 0;
> -: 2:
> -: 3:__attribute__((noinline, noclone)) static int
> 5: 4:last (void)
> -: 5:{
> 5: 6: return ++cnt % 5 == 0;
> -: 7:}
> -: 8:
> -: 9:__attribute__((noinline, noclone)) static void
> 6: 10:do_it (void)
> -: 11:{
> 6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
> 6: 13:}
> -: 14:
> 1: 15:static void f1 (void)
> -: 16:{
> 1: 17: do_it();
> 4: 18: for (; 0<1; do_it())
> -: 19: {
> 5: 20: if (last ())
> 1: 21: break;
> -: 22: }
> 1: 23: do_it ();
> 1: 24:}
> -: 25:
> -: 26:int
> 1: 27:main ()
> -: 28:{
> 1: 29: f1 ();
> -: 30:}
>
> do_it() is indeed called 4 times,but I wonder how the coverage statistiscs
> of the for-statement is calculated. It doesn't become 5 untill the
> for-stamentment is completed.
> -: 0:Source:test.c
> -: 0:Graph:test.gcno
> -: 0:Data:test.gcda
> -: 0:Runs:1
> -: 1:volatile int cnt = 0;
> -: 2:
> -: 3:__attribute__((noinline, noclone)) static int
> 5: 4:last (void)
> -: 5:{
> 5: 6: return ++cnt % 5 == 0;
> -: 7:}
> -: 8:
> -: 9:__attribute__((noinline, noclone)) static void
> 6: 10:do_it (void)
> -: 11:{
> 6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
> 6: 13:}
> -: 14:
> 1: 15:static void f1 (void)
> -: 16:{
> 1: 17: do_it();
> 5: 18: for (int a=0;0<1;do_it())
> -: 19: {
> 5: 20: if (last ())
> 1: 21: break;
> -: 22: }
> 1: 23: do_it ();
> 1: 24:}
> -: 25:
> -: 26:int
> 1: 27:main ()
> -: 28:{
> 1: 29: f1 ();
> -: 30:}
Besides, GCov doesn't seem to provide voerage statistics for "for(;;)" .
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:volatile int cnt = 0;
-: 2:
-: 3:__attribute__((noinline, noclone)) static int
5: 4:last (void)
-: 5:{
5: 6: return ++cnt % 5 == 0;
-: 7:}
-: 8:
-: 9:__attribute__((noinline, noclone)) static void
6: 10:do_it (void)
-: 11:{
6: 12: asm volatile ("" : : "r" (&cnt) : "memory");
6: 13:}
-: 14:
1: 15:static void f1 (void)
-: 16:{
1: 17: do_it();
-: 18: for (; ; )
-: 19: {
5: 20: if (last ())
1: 21: break;
4: 22: do_it();
-: 23: }
1: 24: do_it ();
1: 25:}
-: 26:
-: 27:int
1: 28:main ()
-: 29:{
1: 30: f1 ();
-: 31:}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
` (2 preceding siblings ...)
2022-07-03 3:23 ` njuwy at smail dot nju.edu.cn
@ 2022-07-04 11:36 ` marxin at gcc dot gnu.org
2022-07-04 12:15 ` njuwy at smail dot nju.edu.cn
2022-07-04 13:05 ` njuwy at smail dot nju.edu.cn
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-04 11:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
> do_it() is indeed called 4 times,but I wonder how the coverage statistiscs
> of the for-statement is calculated. It doesn't become 5 untill the
> for-stamentment is completed.
We count a line every time there exists a jump from a different line that jumps
to the line.
Thus for `for(;;)` there are no statements we should jump to.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
` (3 preceding siblings ...)
2022-07-04 11:36 ` marxin at gcc dot gnu.org
@ 2022-07-04 12:15 ` njuwy at smail dot nju.edu.cn
2022-07-04 13:05 ` njuwy at smail dot nju.edu.cn
5 siblings, 0 replies; 7+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2022-07-04 12:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
--- Comment #5 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
(In reply to Martin Liška from comment #4)
> > do_it() is indeed called 4 times,but I wonder how the coverage statistiscs
> > of the for-statement is calculated. It doesn't become 5 untill the
> > for-stamentment is completed.
>
> We count a line every time there exists a jump from a different line that
> jumps to the line.
> Thus for `for(;;)` there are no statements we should jump to.
Thanks for your reply, I have figured it out. "0<1" is used as a conditional
judgment of permanent true, and its execution is optimized away.
I also find that two previously reported issues(#100980,#101618) have
disappeared in the new version.Could you mind doing me a favor to take a look
if you have a minute?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
` (4 preceding siblings ...)
2022-07-04 12:15 ` njuwy at smail dot nju.edu.cn
@ 2022-07-04 13:05 ` njuwy at smail dot nju.edu.cn
5 siblings, 0 replies; 7+ messages in thread
From: njuwy at smail dot nju.edu.cn @ 2022-07-04 13:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106090
--- Comment #6 from Yang Wang <njuwy at smail dot nju.edu.cn> ---
(In reply to Martin Liška from comment #4)
> > do_it() is indeed called 4 times,but I wonder how the coverage statistiscs
> > of the for-statement is calculated. It doesn't become 5 untill the
> > for-stamentment is completed.
>
> We count a line every time there exists a jump from a different line that
> jumps to the line.
> Thus for `for(;;)` there are no statements we should jump to.
Thanks for your confirmation! I will continue to track the progress of open
bugs.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-04 13:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-26 15:06 [Bug gcov-profile/106090] New: [GCOV] Wrong coverage for loop statements njuwy at smail dot nju.edu.cn
2022-06-27 13:45 ` [Bug gcov-profile/106090] " marxin at gcc dot gnu.org
2022-07-03 3:19 ` njuwy at smail dot nju.edu.cn
2022-07-03 3:23 ` njuwy at smail dot nju.edu.cn
2022-07-04 11:36 ` marxin at gcc dot gnu.org
2022-07-04 12:15 ` njuwy at smail dot nju.edu.cn
2022-07-04 13:05 ` njuwy at smail dot nju.edu.cn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).