From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 71B26387090F; Sun, 7 Mar 2021 07:36:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71B26387090F From: "dz1933028 at smail dot nju.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/99440] New: [GCOV] Wrong coverage with callsite Date: Sun, 07 Mar 2021 07:36:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dz1933028 at smail dot nju.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2021 07:36:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99440 Bug ID: 99440 Summary: [GCOV] Wrong coverage with callsite Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: dz1933028 at smail dot nju.edu.cn CC: marxin at gcc dot gnu.org Target Milestone: --- $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto= -wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure -enable-checking=3Drelease -enable-languages= =3Dc,c++ -disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC)=20 $ cat test.c #include extern void abort(void); int v1 =3D 8; long int v2 =3D 3; void *v3 =3D (void *)&v2; struct A { char c[16]; } v4 =3D {"foo"}; long double v5 =3D 40; char seen[20]; int cnt; __attribute__((noinline)) int foo1(int x, int y, ...) { return x; } __attribute__((noinline)) int foo2(int x, int y, ...) { return x + 8; } __attribute__((noinline)) int foo3(void) { return 6; } extern inline __attribute__((always_inline, gnu_inline)) int bar(int x, ...= ) { if (x < 10) return foo1(x, foo3(), 5, __builtin_va_arg_pack()); return foo2(x, foo3() + 4, __builtin_va_arg_pack()); } int main(void) { if (bar(0, ++v1, v4, &v4, v2++) !=3D 0) abort(); if (bar(1, ++v5, 8, v3) !=3D 1) abort(); if (bar(2) !=3D 2) abort(); if (bar(v1 + 2) !=3D 19) abort(); if (bar(v1 + 3, v5--, v4, v4, v3, 16LL) !=3D 20) abort(); return 0; } $ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov File 'test.c' Lines executed:75.00% of 20 Creating 'test.c.gcov' -: 0:Source:test.c -: 0:Graph:test.gcno -: 0:Data:test.gcda -: 0:Runs:1 -: 1:#include -: 2: -: 3:extern void abort(void); -: 4: -: 5:int v1 =3D 8; -: 6:long int v2 =3D 3; -: 7:void *v3 =3D (void *)&v2; -: 8:struct A { -: 9: char c[16]; -: 10:} v4 =3D {"foo"}; -: 11:long double v5 =3D 40; -: 12:char seen[20]; -: 13:int cnt; -: 14: 3: 15:__attribute__((noinline)) int foo1(int x, int y, ...) { 3: 16: return x; -: 17:} -: 18: 2: 19:__attribute__((noinline)) int foo2(int x, int y, ...) { 2: 20: return x + 8; -: 21:} -: 22: 5: 23:__attribute__((noinline)) int foo3(void) { return 6; } -: 24: -: 25:extern inline __attribute__((always_inline, gnu_inline)) int bar(int x, ...) { 1: 26: if (x < 10) 3*: 27: return foo1(x, foo3(), 5, __builtin_va_arg_pack()); 2*: 28: return foo2(x, foo3() + 4, __builtin_va_arg_pack()); -: 29:} -: 30: 1: 31:int main(void) { 2: 32: if (bar(0, ++v1, v4, &v4, v2++) !=3D 0) #####: 33: abort(); 2: 34: if (bar(1, ++v5, 8, v3) !=3D 1) #####: 35: abort(); 1: 36: if (bar(2) !=3D 2) #####: 37: abort(); 2: 38: if (bar(v1 + 2) !=3D 19) #####: 39: abort(); 2: 40: if (bar(v1 + 3, v5--, v4, v4, v3, 16LL) !=3D 20) #####: 41: abort(); 1: 42: return 0; -: 43:} The coverage of line #32,#34,#38 and #40 should be 1 like line #36=