public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-9101] aarch64: Fix sibcalls involving shared-ZT0 functions Date: Wed, 21 Feb 2024 11:13:13 +0000 (GMT) [thread overview] Message-ID: <20240221111313.CD1033858431@sourceware.org> (raw) https://gcc.gnu.org/g:6d56f590483b17c538e332097807a6c5a9225ea3 commit r14-9101-g6d56f590483b17c538e332097807a6c5a9225ea3 Author: Richard Sandiford <richard.sandiford@arm.com> Date: Wed Feb 21 11:12:28 2024 +0000 aarch64: Fix sibcalls involving shared-ZT0 functions In: void bar() __arm_inout("za"); void foo() __arm_inout("za", "zt0") { bar(); } foo cannot tail-call bar because foo needs to restore ZT0 after the call. I'd forgotten to update the ok_for_sibcall rules to handle this when adding SME2. Thanks to Sander de Smalen for the spot. gcc/ * config/aarch64/aarch64.cc (aarch64_function_ok_for_sibcall): Check that each individual piece of state is shared in the same way, rather than using an aggregate check for PSTATE.ZA. gcc/testsuite/ * gcc.target/aarch64/sme/sibcall_9.c: New test. Diff: --- gcc/config/aarch64/aarch64.cc | 6 ++- gcc/testsuite/gcc.target/aarch64/sme/sibcall_9.c | 51 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index de746e28ca5a..f9cedd31bc1b 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -6334,8 +6334,10 @@ aarch64_function_ok_for_sibcall (tree, tree exp) tree fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); if (aarch64_fntype_pstate_sm (fntype) & ~aarch64_cfun_incoming_pstate_sm ()) return false; - if (aarch64_fntype_pstate_za (fntype) != aarch64_cfun_incoming_pstate_za ()) - return false; + for (auto state : { "za", "zt0" }) + if (bool (aarch64_cfun_shared_flags (state)) + != bool (aarch64_fntype_shared_flags (fntype, state))) + return false; return true; } diff --git a/gcc/testsuite/gcc.target/aarch64/sme/sibcall_9.c b/gcc/testsuite/gcc.target/aarch64/sme/sibcall_9.c new file mode 100644 index 000000000000..2e133c881a8a --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sme/sibcall_9.c @@ -0,0 +1,51 @@ +// { dg-options "-O2 -fno-schedule-insns -fno-schedule-insns2" } +// { dg-final { check-function-bodies "**" "" } } + +#pragma GCC target "+sme2" + +void gen_zt0() __arm_preserves("za") __arm_out("zt0"); +void callee() __arm_inout("za"); + +/* +** caller_inout: +** ... +** str zt0, \[[^\n]+\] +** bl callee +** ldr zt0, \[[^\n]+\] +** ... +** ret +*/ +void caller_inout() __arm_inout("za", "zt0") { callee(); } + +/* +** caller_in: +** ... +** str zt0, \[[^\n]+\] +** bl callee +** ldr zt0, \[[^\n]+\] +** ... +** ret +*/ +void caller_in() __arm_inout("za") __arm_in("zt0") { callee(); } + +/* +** caller_out: +** ... +** str zt0, \[[^\n]+\] +** bl callee +** ldr zt0, \[[^\n]+\] +** ... +** ret +*/ +void caller_out() __arm_inout("za") __arm_in("zt0") { gen_zt0(); callee(); } + +/* +** caller_preserves: +** ... +** str zt0, \[[^\n]+\] +** bl callee +** ldr zt0, \[[^\n]+\] +** ... +** ret +*/ +void caller_preserves() __arm_inout("za") __arm_preserves("zt0") { callee(); }
reply other threads:[~2024-02-21 11:13 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=20240221111313.CD1033858431@sourceware.org \ --to=rsandifo@gcc.gnu.org \ --cc=gcc-cvs@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).