public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114848] New: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
@ 2024-04-25  7:45 pinskia at gcc dot gnu.org
  2024-04-25  8:00 ` [Bug target/114848] " xry111 at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-25  7:45 UTC (permalink / raw)
  To: gcc-bugs

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
```

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-30  1:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25  7:45 [Bug target/114848] New: longarch: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
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

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).