public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114848] New: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return Date: Thu, 25 Apr 2024 07:45:18 +0000 [thread overview] Message-ID: <bug-114848-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114848 Bug ID: 114848 Summary: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: longarch64-linux-gnu I reduced an miscompile for aarch64 inside _Unwind_RaiseException and I noticed the same issue can be reproduced on powerpc64-linux-gnu and powerpc-linux-gnu. Reduced testcase: ``` __attribute__((noipa,noinline)) int f(int *a, long offset, void *handler) { if (*a == 5) return 5; __builtin_eh_return (offset, handler); } int main() { int t = 5; if (f(&t, 0, 0) != 5) __builtin_abort(); } ``` This produces a load (of r4) in the epilogue part for the `return 5` path (which is reduced from the end of stack path inside _Unwind_RaiseException). ``` bne $r13,$r12,.L2 addi.w $r4,$r0,5 # 0x5 or $r8,$r0,$r0 .L4: ld.d $r1,$r3,40 .cfi_remember_state .cfi_restore 1 ld.d $r5,$r3,24 .cfi_restore 5 ld.d $r4,$r3,32 .cfi_restore 4 ld.d $r6,$r3,16 .cfi_restore 6 ld.d $r7,$r3,8 .cfi_restore 7 addi.d $r3,$r3,48 .cfi_def_cfa_offset 0 add.d $r3,$r3,$r8 jr $r1 ```
next reply other threads:[~2024-04-25 7:45 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-25 7:45 pinskia at gcc dot gnu.org [this message] 2024-04-25 8:00 ` [Bug target/114848] " xry111 at gcc dot gnu.org 2024-04-25 8:04 ` pinskia at gcc dot gnu.org 2024-04-25 8:11 ` [Bug target/114848] loongarch: " xry111 at gcc dot gnu.org 2024-04-25 8:21 ` pinskia at gcc dot gnu.org 2024-04-27 9:05 ` chenglulu at loongson dot cn 2024-04-30 1:09 ` cvs-commit at gcc dot gnu.org 2024-04-30 1:11 ` cvs-commit at gcc dot gnu.org 2024-04-30 1:20 ` xry111 at gcc dot gnu.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-114848-4@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).