public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/114824] New: gcc doesn't respect __attribute__((zero_call_used_regs("used"))) when performing a tail call optimization
@ 2024-04-23 10:24 mikulas at artax dot karlin.mff.cuni.cz
0 siblings, 0 replies; only message in thread
From: mikulas at artax dot karlin.mff.cuni.cz @ 2024-04-23 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114824
Bug ID: 114824
Summary: gcc doesn't respect
__attribute__((zero_call_used_regs("used"))) when
performing a tail call optimization
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: mikulas at artax dot karlin.mff.cuni.cz
Target Milestone: ---
If a function has the attribute __attribute__((zero_call_used_regs("used")))
and the function ends with a sibling call, the used registers are not zeroed.
See this function:
#include <stdio.h>
__attribute__((zero_call_used_regs("used"))) void f(void)
{
__asm__ volatile("" ::: "x0", "x1", "x2", "x3", "x4", "x5", "x6",
"x7");
printf("Hello World!\n");
}
Compile it with "gcc -S -o - -O2 call.c -Wall -Wextra" - the result is:
f:
adrp x0, .LC0
add x0, x0, :lo12:.LC0
b puts
If we disable the tail call optimization, the registers x0 - x7 are cleared
properly:
gcc -S -o - -O2 call.c -Wall -Wextra -fno-optimize-sibling-calls
f:
stp x29, x30, [sp, -16]!
mov x29, sp
adrp x0, .LC0
add x0, x0, :lo12:.LC0
bl puts
ldp x29, x30, [sp], 16
mov x0, 0
mov x1, 0
mov x2, 0
mov x3, 0
mov x4, 0
mov x5, 0
mov x6, 0
mov x7, 0
mov x16, 0
mov x17, 0
ret
I tested it on arm64 and x86-64 and both of them suffer from this problem.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-23 10:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 10:24 [Bug middle-end/114824] New: gcc doesn't respect __attribute__((zero_call_used_regs("used"))) when performing a tail call optimization mikulas at artax dot karlin.mff.cuni.cz
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).