From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5582A3858408; Sun, 2 Jan 2022 14:40:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5582A3858408 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: Sun, 02 Jan 2022 14:40:27 +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: WORKSFORME 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: resolution 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: Sun, 02 Jan 2022 14:40:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103882 Jose Silva changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |WORKSFORME --- Comment #15 from Jose Silva --- > IPA RA is a very useful optimization, not something terrible. > that would penalize millions of correctly written inline asm statements i= n real-world code It's a useful optimization but GCC offers a terrible implementation of it.= =20 As I elaborated before, if I have to always tell the compiler what my inline asm is doing then it's just garbage. If no clobber information is provided the compiler should just bail out of = the IPA RA for that given function and follow the ABI strictly. It could also e= mit a warning telling the programmer that by not providing clobber information = the optimization is not as good. With clobber information it should just trust the programmer. If by "correctly written inline asm statements" you mean statements with clobber information, then they wouldn't be penalized because they are provi= ding the necessary information. ~Sensible defaults~ is what I'm talking about. Have you considered that users don't want to RE the kernel just to see what registers are being clobbered? The ABI exists for that reason, if everyone follows that there is no problem. > (except that __attribute__((naked)) > Or just use the syscall function, see syscall(2) man page. > And I've only spent last 23+ years working on GCC, so yes, I can't know t= he > codebase enough. naked is not supported as an attribute for MIPS targets. It was the first t= hing I tried when trying to stop the compiler from optimizing the code. The `syscall` function is useless for me because the platform I'm targeting passes the number in $v1 and not $a0. And as I said in the original post, I= 'm using `-nostdlib' so there's no access to the `syscall` function. Stop making bad suggestions to try and justify a bad compiler optimization implementation. > A hack that you want to propose (forcing noipa on functions that use inli= ne asm) certainly won't be accepted I have no interest in upstreaming my changes. It was clear from the thread = you had no interest in it. I just requested some guidance on the toxic wasteland that is the GCC codebase. If you don't want to help, don't bother respondin= g.=