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: Sat, 01 Jan 2022 12:45:06 +0000	[thread overview]
Message-ID: <bug-103882-4-H0VgkvJIW9@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

--- Comment #6 from Jose Silva <krystalgamer at protonmail dot com> ---
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-asm
> 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 <test>:
a0020060:       27bdfff0        addiu   sp,sp,-16
a0020064:       ffb00000        sd      s0,0(sp)
a0020068:       ffbf0008        sd      ra,8(sp)
a002006c:       0c008016        jal     a0020058 <fail>
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 <is_first_char_a>
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.

  parent reply	other threads:[~2022-01-01 12:45 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 [this message]
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
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-H0VgkvJIW9@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).