From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 095303858C27; Sat, 1 Jan 2022 12:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 095303858C27 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 12:45:06 +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 12:45:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103882 --- Comment #6 from Jose Silva --- Yes, noipa does help. (In reply to Andrew Pinski from comment #3) > Oh that is because there is some IPA Register allocation going on. Anyways > this is still not a bug. You need to mark a0 as a clobber in the inline-a= sm > to let GCC know that a0 is touched. As I said I simplified the example, the original code had a syscall which I have no idea which registers will be clobbered. Before upgrading compilers I was using GCC 3.2 which produces the following code with `-nostdlib -Os`: ``` a0020060 : a0020060: 27bdfff0 addiu sp,sp,-16 a0020064: ffb00000 sd s0,0(sp) a0020068: ffbf0008 sd ra,8(sp) a002006c: 0c008016 jal a0020058 a0020070: 0080802d move s0,a0 a0020074: 0200202d move a0,s0 a0020078: dfbf0008 ld ra,8(sp) a002007c: dfb00000 ld s0,0(sp) a0020080: 08008012 j a0020048 a0020084: 27bd0010 addiu sp,sp,16 ``` I'm quite confused on why you say "Anyways this is still not a bug". IPA RA= is making assumptions on procedures where it does not have enough information = to do so, i.e functions with asm statements. It is disabled when a function pointer is used, why shouldn't it be for when a function with ASM statement= is encountered? The code inside the `fail()` function is valid and does not break the ABI, = GCC does not have enough information to perform IPA RA but does so(wrongly), to= me that's a bug.=