From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9C8C83858D3C; Mon, 17 Jan 2022 22:20:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C8C83858D3C From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/95558] [9/10/11/12 Regression] Invalid IPA optimizations based on weak definition Date: Mon, 17 Jan 2022 22:20:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 9.5 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 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: Mon, 17 Jan 2022 22:20:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95558 --- Comment #12 from Andrew Pinski --- (In reply to Rich Felker from comment #11) > Are you sure? If pure/const discovery is no longer applied to weak > definitions, it shouldn't be able to propagate to a non-inlined caller. Of > course the fix may be incomplete or not working, which I guess we could t= ell > from whether it happened prior to or after comment 5. :) There still looks like there is a bug as shown by taking the original testc= ase in comment #0 and using -O2 -fno-inline, you will get: reclaim_gaps: ret ... foo: ret Which is still wrong as reclaim should not be considered as pure. >>From *.pure-const: Starting cycle Visiting donate_dummy/0 state:const looping 0 Result const looping 0 Function found not to call free: donate_dummy/0 Starting cycle Visiting reclaim/2 state:pure looping 0 Call to __malloc_donate/1 const Result pure looping 0 Function found to be pure: reclaim/2 Declaration updated to be pure: reclaim/2 Starting cycle Visiting reclaim_gaps/3 state:pure looping 0 Call to reclaim/2 state:pure looping:0 Call to reclaim/2 state:pure looping:0 Result pure looping 0 Function found to be pure: reclaim_gaps/3 Declaration updated to be pure: reclaim_gaps/3 Starting cycle Visiting foo/4 state:const looping 0 Call to reclaim_gaps/3 state:pure looping:0 Result pure looping 0 Function found to be pure: foo/4 Declaration updated to be pure: foo/4 reclaim, reclaim_gaps and foo are all found as pure. without -fno-inline, we get some early inlining which causes the difference there.=