From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 39E893858D38 for ; Wed, 24 Jan 2024 17:43:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39E893858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 39E893858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706118215; cv=none; b=aQEZuLgA7Jlfp9DEsQ+OKuB6mGpsSfaZFgr8IyRA/cGgm5OzF8J2hbVmw3lVn7I6UfxYigOkkT8ftZU7il9EU/HvM3tpK3bqkeT+5OriEGZhU6PKeGVBxWXhWgC2CQk0nx9k5w/6MVErYyPrB5SH6IMx2JNmVN6UMc1DeAh95T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706118215; c=relaxed/simple; bh=nZJ91GtPcPyDmCDCgp1YiZkxUegbJmR3tDCmfahSBZE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=O59D7FEn5+x3bQNNnATNnTXnSApGXdRjOCW5DlTVjpPnyQ1mh/RB5c6PeIk5NVm7/yQIxy7OG4pRWYzE1LlBdaoGdW+u31Ycqj6jEJrm/zC4cRaei4G/l2d3R7HLUN9izX7pDl3L/phnYpiXF6b62/lD/wiY8EpqdsWItNu39f8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B5B8A1FB; Wed, 24 Jan 2024 09:44:17 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FCB33F762; Wed, 24 Jan 2024 09:43:32 -0800 (PST) From: Richard Sandiford To: Andrew Pinski Mail-Followup-To: Andrew Pinski ,, richard.sandiford@arm.com Cc: Subject: Re: [PATCH] aarch64: Fix __builtin_apply with -mgeneral-regs-only [PR113486] References: <20240118215730.1012858-1-quic_apinski@quicinc.com> Date: Wed, 24 Jan 2024 17:43:31 +0000 In-Reply-To: <20240118215730.1012858-1-quic_apinski@quicinc.com> (Andrew Pinski's message of "Thu, 18 Jan 2024 13:57:30 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-21.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Andrew Pinski writes: > 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. OK, thanks. Richard > Signed-off-by: Andrew Pinski > --- > gcc/config/aarch64/aarch64.cc | 4 ++++ > gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c | 12 ++++++++++++ > 2 files changed, 16 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/aarch64/builtin_apply-1.c > > diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc > index e6bd3fd0bb4..a838cbba51d 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); > +}