From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id 972433858D38; Wed, 24 Jan 2024 17:50:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 972433858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706118600; bh=fNKPfkON70VAheG9gAoE8nG7TPEIN0hRulTCknyqnR8=; h=From:To:Subject:Date:From; b=GT9qt/zVJtbYnGOFM91Jg/FJ2UnPq7tIJD9P0aXPKq3d59XMnArlfUsoM2CH9lYKQ v4kXHHXLinTdmhpGXzxabU1S6Wo65zH61bmcZj5HB3doEphRuGLa8w7s7Okxgm5rtj TRssf098xH/q57BlWkgGzbM4iBqB+40GixPiW9fQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8397] aarch64: Fix __builtin_apply with -mgeneral-regs-only [PR113486] X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: fb54b9772816968032518d4008be5090e0d95109 X-Git-Newrev: d3ff08a3764f2047d02b35212fc4f1da9eb75c7b Message-Id: <20240124175000.972433858D38@sourceware.org> Date: Wed, 24 Jan 2024 17:50:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d3ff08a3764f2047d02b35212fc4f1da9eb75c7b commit r14-8397-gd3ff08a3764f2047d02b35212fc4f1da9eb75c7b Author: Andrew Pinski Date: Thu Jan 18 10:40:04 2024 -0800 aarch64: Fix __builtin_apply with -mgeneral-regs-only [PR113486] The problem here is the builtin apply mechanism thinks the FP registers are to be used due to get_raw_arg_mode not returning VOIDmode. This fixes that oversight and the backend now returns VOIDmode for non-general-regs if TARGET_GENERAL_REGS_ONLY is true. Built and tested for aarch64-linux-gnu with no regressions. PR target/113486 gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_get_reg_raw_mode): For TARGET_GENERAL_REGS_ONLY, return VOIDmode for non-GP_REGNUM_P regno. gcc/testsuite/ChangeLog: * gcc.target/aarch64/builtin_apply-1.c: New test. Signed-off-by: Andrew Pinski Diff: --- gcc/config/aarch64/aarch64.cc | 4 ++++ gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index c54b6067949..3d6dd98c5c5 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -7221,6 +7221,10 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type) static fixed_size_mode aarch64_get_reg_raw_mode (int regno) { + /* Don't use any non GP registers for __builtin_apply and + __builtin_return if general registers only mode is requested. */ + if (TARGET_GENERAL_REGS_ONLY && !GP_REGNUM_P (regno)) + return as_a (VOIDmode); if (TARGET_SVE && FP_REGNUM_P (regno)) /* Don't use the SVE part of the register for __builtin_apply and __builtin_return. The SVE registers aren't used by the normal PCS, diff --git a/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c b/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c new file mode 100644 index 00000000000..d70abe037d2 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mgeneral-regs-only" } */ +/* PR target/113486 */ + + +/* __builtin_apply should not use FP registers if + general registers only mode is requested. */ +void +foo (void) +{ + __builtin_apply (foo, 0, 0); +}