From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B33A3858C50; Thu, 9 Feb 2023 10:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B33A3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675938228; bh=ofu/Ui8Mw/62DEWff/AI8/qdzlY1Wh2RseljQqBgK7U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LR8GPpg476jYJJgMEKFsbc6XkmIRnndOr4tTxfp50waKj0US/Ta3Zhc+g5GzshUzj A+8WC3eTOKvgiGB3N/VT/ceKYVu6t0+5Wvre5cUpJQ+snCjZxqndCrra3AdiQYuwKy DFkkLyw/lAzGTfI+k+zXLT9wY6w91/Fc1gMk3aPQ= From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/108658] [GCOV] Function entry is not recorded in a function containing an infinite loop from another thread depending on the optimization level Date: Thu, 09 Feb 2023 10:23:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108658 --- Comment #8 from Martin Li=C5=A1ka --- (In reply to Richard Biener from comment #7) > -fno-move-loop-stores disables the store motion. Ok, so I can confirm both -fno-move-loop-stores or -fprofile-update=3Datomi= c lead to properly collected numbers with -O2: $ rm *gcda ; gcc pr108658.c -O2 idle.c --coverage -fprofile-update=3Datomic= && ./a.out && gcov-dump -l a-idle.gcda a-idle.gcda:data:magic `gcda':version `B30 ' a-idle.gcda:stamp 900763911 a-idle.gcda:checksum 3617524158 a-idle.gcda: a1000000: 8:OBJECT_SUMMARY runs=3D1, sum_max=3D711808344 a-idle.gcda: 01000000: 12:FUNCTION ident=3D2013603264, lineno_checksum=3D0x5f7f7dbf, cfg_checksum=3D0xc48fabfe a-idle.gcda: 01a10000: 8:COUNTERS arcs 1 counts a-idle.gcda: 0: 711842716=20 However, we still end up with zero execution number of the problematic line: gcov -t a-idle.gcda -: 0:Source:idle.c -: 0:Graph:a-idle.gcno -: 0:Data:a-idle.gcda -: 0:Runs:1 #####: 1:void *idle(void *ignored) -: 2:{ -: 3: while (1) { -: 4: /* Do nothing */ -: 5: } -: 6: -: 7: return 0; -: 8:} That's caused by many empty blocks at the time of the creation of the note file: (gdb) pcfun void * idle (void * ignored) { [local count: 10631108]: [local count: 1073741824]: [local count: 1073741824]: goto ; [100.00%] } $ gcov-dump -l a-idle.gcno a-idle.gcno:note:magic `gcno':version `B30 ' a-idle.gcno:stamp 900904516 a-idle.gcno:checksum 0 a-idle.gcno:cwd: /home/marxin/Programming/testcases a-idle.gcno: 01000000: 52:FUNCTION ident=3D2013603264, lineno_checksum=3D0x5f7f7dbf, cfg_checksum=3D0xc48fabfe, `idle' idle.c:1:7-= 8:1 a-idle.gcno: 01410000: 4:BLOCKS 5 blocks a-idle.gcno: 01430000: 12:ARCS 1 arcs a-idle.gcno: block 0: 2:0005(tree,fall) a-idle.gcno: 01430000: 12:ARCS 1 arcs a-idle.gcno: block 2: 3:0005(tree,fall) a-idle.gcno: 01430000: 12:ARCS 1 arcs a-idle.gcno: block 3: 4:0004(fall) a-idle.gcno: 01430000: 12:ARCS 1 arcs a-idle.gcno: block 4: 3:0005(tree,fall) a-idle.gcno: 01450000: 31:LINES a-idle.gcno: block 2:`idle.c':1 so with -O2 we only tract function entrance (idle.c:1) and it belongs to bl= ock 2, but the looping happens in BBs 3->4. So we loose the tracking.=