public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
@ 2024-04-25 7:34 pinskia at gcc dot gnu.org
2024-04-25 9:23 ` [Bug target/114846] " linkw at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-25 7:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
Bug ID: 114846
Summary: powerpc: 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: powerpc64-linux-gnu powerpc-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 in the epilogue part for the `return 5` path (which is
reduced from the end of stack path inside _Unwind_RaiseException).
```
li 3,5
li 10,0
.L4:
ld 2,40(1)
ld 4,-24(1)
ld 5,-16(1)
ld 6,-8(1)
ld 3,-32(1)
add 1,1,10
blr
```
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
@ 2024-04-25 9:23 ` linkw at gcc dot gnu.org
2024-04-25 9:25 ` linkw at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-04-25 9:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
Kewen Lin <linkw at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2024-04-25
Status|UNCONFIRMED |NEW
CC| |bergner at gcc dot gnu.org,
| |linkw at gcc dot gnu.org,
| |segher at gcc dot gnu.org
Target|powerpc64-linux-gnu |powerpc64*-linux-gnu
|powerpc-linux-gnu |powerpc-linux-gnu
--- Comment #1 from Kewen Lin <linkw at gcc dot gnu.org> ---
Thanks for reporting, confirmed, it also fails on LE (ppc64le-linux).
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
2024-04-25 9:23 ` [Bug target/114846] " linkw at gcc dot gnu.org
@ 2024-04-25 9:25 ` linkw at gcc dot gnu.org
2024-04-25 21:37 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-04-25 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #2 from Kewen Lin <linkw at gcc dot gnu.org> ---
As https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114843#c8, we may need some
similar handling like r14-6440-g4b421728289e6f.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
2024-04-25 9:23 ` [Bug target/114846] " linkw at gcc dot gnu.org
2024-04-25 9:25 ` linkw at gcc dot gnu.org
@ 2024-04-25 21:37 ` pinskia at gcc dot gnu.org
2024-04-29 5:20 ` linkw at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-25 21:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Kewen Lin from comment #2)
> As https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114843#c8, we may need some
> similar handling like r14-6440-g4b421728289e6f.
Note rs6000_emit_epilogue mostly handles eh_returns so it might not be as hard
as other targets.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2024-04-25 21:37 ` pinskia at gcc dot gnu.org
@ 2024-04-29 5:20 ` linkw at gcc dot gnu.org
2024-04-29 9:04 ` linkw at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-04-29 5:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
Kewen Lin <linkw at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |linkw at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #4 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Kewen Lin from comment #2)
> > As https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114843#c8, we may need some
> > similar handling like r14-6440-g4b421728289e6f.
>
> Note rs6000_emit_epilogue mostly handles eh_returns so it might not be as
> hard as other targets.
Yes, making a patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (3 preceding siblings ...)
2024-04-29 5:20 ` linkw at gcc dot gnu.org
@ 2024-04-29 9:04 ` linkw at gcc dot gnu.org
2024-05-14 8:49 ` linkw at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-04-29 9:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #5 from Kewen Lin <linkw at gcc dot gnu.org> ---
Created attachment 58067
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58067&action=edit
untested patch
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (4 preceding siblings ...)
2024-04-29 9:04 ` linkw at gcc dot gnu.org
@ 2024-05-14 8:49 ` linkw at gcc dot gnu.org
2024-05-29 2:15 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-05-14 8:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
Kewen Lin <linkw at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #58067|0 |1
is obsolete| |
--- Comment #6 from Kewen Lin <linkw at gcc dot gnu.org> ---
Created attachment 58201
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58201&action=edit
tested patch
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (5 preceding siblings ...)
2024-05-14 8:49 ` linkw at gcc dot gnu.org
@ 2024-05-29 2:15 ` cvs-commit at gcc dot gnu.org
2024-05-29 2:33 ` linkw at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-29 2:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kewen Lin <linkw@gcc.gnu.org>:
https://gcc.gnu.org/g:e5fc5d42d25c86ae48178db04ce64d340a834614
commit r15-884-ge5fc5d42d25c86ae48178db04ce64d340a834614
Author: Kewen Lin <linkw@linux.ibm.com>
Date: Tue May 28 21:13:40 2024 -0500
rs6000: Don't clobber return value when eh_return called [PR114846]
As the associated test case in PR114846 shows, currently
with eh_return involved some register restoring for EH
RETURN DATA in epilogue can clobber the one which holding
the return value. Referring to the existing handlings in
some other targets, this patch makes eh_return expander
call one new define_insn_and_split eh_return_internal which
directly calls rs6000_emit_epilogue with epilogue_type
EPILOGUE_TYPE_EH_RETURN instead of the previous treating
normal return with crtl->calls_eh_return specially.
PR target/114846
gcc/ChangeLog:
* config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): As
EPILOGUE_TYPE_EH_RETURN would be passed as epilogue_type directly
now, adjust the relevant handlings on it.
* config/rs6000/rs6000.md (eh_return expander): Append by calling
gen_eh_return_internal and emit_barrier.
(eh_return_internal): New define_insn_and_split, call function
rs6000_emit_epilogue with epilogue type EPILOGUE_TYPE_EH_RETURN.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr114846.c: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (6 preceding siblings ...)
2024-05-29 2:15 ` cvs-commit at gcc dot gnu.org
@ 2024-05-29 2:33 ` linkw at gcc dot gnu.org
2024-05-29 12:30 ` bergner at gcc dot gnu.org
2024-05-29 12:50 ` linkw at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-05-29 2:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #8 from Kewen Lin <linkw at gcc dot gnu.org> ---
Should be fixed on trunk, it's not a regression, but we probably want
backporting this?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (7 preceding siblings ...)
2024-05-29 2:33 ` linkw at gcc dot gnu.org
@ 2024-05-29 12:30 ` bergner at gcc dot gnu.org
2024-05-29 12:50 ` linkw at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: bergner at gcc dot gnu.org @ 2024-05-29 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #9 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to Kewen Lin from comment #8)
> Should be fixed on trunk, it's not a regression, but we probably want
> backporting this?
For code correctness bugs, yes, we want them backported.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/114846] powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
` (8 preceding siblings ...)
2024-05-29 12:30 ` bergner at gcc dot gnu.org
@ 2024-05-29 12:50 ` linkw at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: linkw at gcc dot gnu.org @ 2024-05-29 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114846
--- Comment #10 from Kewen Lin <linkw at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #9)
> (In reply to Kewen Lin from comment #8)
> > Should be fixed on trunk, it's not a regression, but we probably want
> > backporting this?
>
> For code correctness bugs, yes, we want them backported.
Thanks for confirming! Will do backporting after burn-in time.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-05-29 12:50 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 7:34 [Bug target/114846] New: powerpc: epilogue in _Unwind_RaiseException corrupts return value due to __builtin_eh_return pinskia at gcc dot gnu.org
2024-04-25 9:23 ` [Bug target/114846] " linkw at gcc dot gnu.org
2024-04-25 9:25 ` linkw at gcc dot gnu.org
2024-04-25 21:37 ` pinskia at gcc dot gnu.org
2024-04-29 5:20 ` linkw at gcc dot gnu.org
2024-04-29 9:04 ` linkw at gcc dot gnu.org
2024-05-14 8:49 ` linkw at gcc dot gnu.org
2024-05-29 2:15 ` cvs-commit at gcc dot gnu.org
2024-05-29 2:33 ` linkw at gcc dot gnu.org
2024-05-29 12:30 ` bergner at gcc dot gnu.org
2024-05-29 12:50 ` linkw 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).