public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "njuwy at smail dot nju.edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/106090] [GCOV] Wrong coverage for loop statements
Date: Sun, 03 Jul 2022 03:23:37 +0000 [thread overview]
Message-ID: <bug-106090-4-nC4ZeAhW0m@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106090-4@http.gcc.gnu.org/bugzilla/>
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:}
next prev parent reply other threads:[~2022-07-03 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-26 15:06 [Bug gcov-profile/106090] New: " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-106090-4-nC4ZeAhW0m@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).