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: Fri, 31 Dec 2021 20:48:50 +0000 [thread overview] Message-ID: <bug-103882-4-VWb3Utl324@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 ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #2 from Jose Silva <krystalgamer at protonmail dot com> --- Marking as noinline does not help. See the generated code: ``` 0040014c <example>: 40014c: 27bdffe0 addiu sp,sp,-32 400150: afbf001c sw ra,28(sp) 400154: 0c100050 jal 400140 <fail> 400158: 00000000 nop 40015c: 80820000 lb v0,0(a0) 400160: 8fbf001c lw ra,28(sp) 400164: 27bd0020 addiu sp,sp,32 400168: 38420061 xori v0,v0,0x61 40016c: 03e00008 jr ra 400170: 2c420001 sltiu v0,v0,1 ``` The marking as a clobbered does work, but it doesn't fix the underlying issue. On my original code I had a `syscall`, which passes the code execution to the kernel that I have no control over or know the full implementation. The specific syscall was overwriting the $a0 register which I simplified in my example. GCC when -O2 is enabled is making too strong assumptions about the code. To better illustrate the issue, let me give another example. If I call a function via a function pointer regardless of the optimization level, GCC will save all caller-saved registers in use. But when it encounters an ASM statement it treats it like it doesn't exist. In my opinion, the same assumptions made when calling from a function pointer should apply when calling a function with inline-asm*. * Manually indicating the clobbered registers could override this behaviour
next prev parent reply other threads:[~2021-12-31 20:48 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 [this message] 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 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-VWb3Utl324@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: linkBe 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).