From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2FF9A3858C27; Sat, 1 Jan 2022 15:06:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FF9A3858C27 From: "krystalgamer at protonmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103882] Register corruption in ASM only functions when optization is -O2/-Os/-O3 Date: Sat, 01 Jan 2022 15:06:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: inline-asm X-Bugzilla-Severity: normal X-Bugzilla-Who: krystalgamer at protonmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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 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: Sat, 01 Jan 2022 15:06:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103882 --- Comment #9 from Jose Silva --- (In reply to Jakub Jelinek from comment #7) > The compiler has no idea either (it has intentionally no idea what the > inline asm does, it is a black box to the compiler), so that is why you n= eed > to specify it. Look at C library sources, or kernel and find out what is > and what isn't clobbered and add the clobbers. It seems weird that GCC puts the sole responsibility on the programmer when dealing with ASM. In my honest opinion, the compiler should be cautious when interacting with hand-written ASM, the same way when interacting with funct= ion pointers.=20 It does allow for more optimization opportunities but it implies the progra= mmer knows a lot about the underlying architecture and system. I'd like to implement a feature that automatically sets a function as noipa when containing ASM statements, could you please point me in the codebase w= here I could start?=