public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "krystalgamer at protonmail dot com" <gcc-bugzilla@gcc.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: Sun, 02 Jan 2022 14:40:27 +0000	[thread overview]
Message-ID: <bug-103882-4-dSnsyoTmr5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103882-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103882

Jose Silva <krystalgamer at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |WORKSFORME

--- Comment #15 from Jose Silva <krystalgamer at protonmail dot com> ---
> IPA RA is a very useful optimization, not something terrible.
> that would penalize millions of correctly written inline asm statements in real-world code

It's a useful optimization but GCC offers a terrible implementation of it. 
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 emit
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 providing
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 the
> codebase enough.

naked is not supported as an attribute for MIPS targets. It was the first thing
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 inline 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 responding.

  parent reply	other threads:[~2022-01-02 14:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31 17:11 [Bug target/103882] New: " krystalgamer at protonmail dot com
2021-12-31 18:53 ` [Bug target/103882] " pinskia at gcc dot gnu.org
2021-12-31 20:48 ` krystalgamer at protonmail dot com
2021-12-31 20:51 ` pinskia at gcc dot gnu.org
2021-12-31 20:51 ` pinskia at gcc dot gnu.org
2021-12-31 22:36 ` jakub at gcc dot gnu.org
2022-01-01 12:45 ` krystalgamer at protonmail dot com
2022-01-01 14:05 ` jakub at gcc dot gnu.org
2022-01-01 14:11 ` jakub at gcc dot gnu.org
2022-01-01 15:06 ` krystalgamer at protonmail dot com
2022-01-01 16:37 ` jakub at gcc dot gnu.org
2022-01-01 19:19 ` krystalgamer at protonmail dot com
2022-01-01 19:47 ` schwab@linux-m68k.org
2022-01-01 20:34 ` jakub at gcc dot gnu.org
2022-01-01 23:15 ` krystalgamer at protonmail dot com
2022-01-02 13:27 ` jakub at gcc dot gnu.org
2022-01-02 14:40 ` krystalgamer at protonmail dot com [this message]
2022-01-02 15:00 ` schwab@linux-m68k.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103882-4-dSnsyoTmr5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).