From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 389403858C27; Sat, 1 Jan 2022 14:05:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 389403858C27 From: "jakub at gcc dot gnu.org" 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 14:05:09 +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: jakub at gcc dot gnu.org 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 14:05:09 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103882 --- Comment #7 from Jakub Jelinek --- (In reply to Jose Silva from comment #6) > Yes, noipa does help. >=20 > (In reply to Andrew Pinski from comment #3) > > Oh that is because there is some IPA Register allocation going on. Anyw= ays > > this is still not a bug. You need to mark a0 as a clobber in the inline= -asm > > to let GCC know that a0 is touched. >=20 > As I said I simplified the example, the original code had a syscall which= I > have no idea which registers will be clobbered. The compiler has no idea either (it has intentionally no idea what the inli= ne asm does, it is a black box to the compiler), so that is why you need to specify it. Look at C library sources, or kernel and find out what is and = what isn't clobbered and add the clobbers. > 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 w= hen > a function pointer is used, why shouldn't it be for when a function with = ASM > statement is encountered? Inline asms need to tell the compiler what registers they are setting, which they are using and what they are clobbering, otherwise the shouldn't set, u= se or clobber anything... You can still e.g. save and restore the registers yourself in the inline asm...=