public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mikulas at artax dot karlin.mff.cuni.cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/114824] New: gcc doesn't respect __attribute__((zero_call_used_regs("used"))) when performing a tail call optimization Date: Tue, 23 Apr 2024 10:24:19 +0000 [thread overview] Message-ID: <bug-114824-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
reply other threads:[~2024-04-23 10:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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-114824-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).