From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F3261384BC3A; Tue, 6 Jul 2021 22:33:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3261384BC3A From: "2-gnu at 0x2c dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug inline-asm/101354] New: [11/12 regression] naked function mishandled - store optimized away Date: Tue, 06 Jul 2021 22:33:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: inline-asm X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 2-gnu at 0x2c dot org 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_file_loc bug_status bug_severity priority component assigned_to reporter 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: Tue, 06 Jul 2021 22:33:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101354 Bug ID: 101354 Summary: [11/12 regression] naked function mishandled - store optimized away Product: gcc Version: 11.0 URL: https://godbolt.org/z/4T4x8eb4f Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: 2-gnu at 0x2c dot org Target Milestone: --- Stores are optimized away when a pointer is passed to a naked function. Discovered in Nordic nRF5-SDK (17.0.2), which uses such a construct to implement syscalls. Minimal example: __attribute__((naked)) //// switching to O0 will make it work //__attribute__((optimize("O0"))) static void extfun_ptr(int *a) { __asm volatile(""); } void fun() { int v; v =3D 1; extfun_ptr(&v); // &v is never initialized }=