From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6FF2E3851C37; Tue, 28 Apr 2020 12:43:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FF2E3851C37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588077831; bh=L5gAhHXi8haPzwjVfky/pCDeCHqFPRey06zuFYb8hoQ=; h=From:To:Subject:Date:From; b=d7Yu1q3y70VuZ5ocR7feAt1OrMRm/AZC0qb0yHsWMjnn23GwJWXhthyDYh80pAUhD Dmd6YEuZYecwUJ47/AdK2ffhHmmw5sBBCqypVFXmqPav3s+akItDHVOM/RpCgzHKO0 PgFdatMgajSkoiqCO21IfPnTv3xGnUr286u8D19o= From: "felix.von.s at posteo dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94818] New: GCC emits dead bodies of functions whose all calls have been eliminated by optimisations Date: Tue, 28 Apr 2020 12:43:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: felix.von.s at posteo dot de 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget 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: Tue, 28 Apr 2020 12:43:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94818 Bug ID: 94818 Summary: GCC emits dead bodies of functions whose all calls have been eliminated by optimisations Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: felix.von.s at posteo dot de Target Milestone: --- Target: x86_64-linux-gnu In this code: __attribute__((__warning__("argh"))) static void foo(void) { __asm__ ( ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ); } void bar0(int x) { if (__builtin_constant_p(x)) foo(); } void bar1(int x) { if (__builtin_constant_p(x)) foo(); } No calls to foo are emitted in the final output, and GCC knows this, since = no warnings are emitted. However, GCC will still emit a function body for foo, unless either the __asm__ statement is removed or both conditions are chang= ed to integer constant expressions, so that the function is eliminated by one = of the inlining passes. (I decided to demonstrate it this way instead of using __attribute__((__noinline__)), just to make sure this is not related to __attribute__((__noinline__)) somehow implying __attribute__((__used__)).)=