From patchwork Wed Mar 27 18:29:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 87727 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B33FB3858C98 for ; Wed, 27 Mar 2024 18:30:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 758FA3858C98 for ; Wed, 27 Mar 2024 18:30:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 758FA3858C98 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 758FA3858C98 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=1711564204; cv=none; b=OKeOhMAlCb9Qxa8e7BTtictWFjL8igaGNqBPuJHS4ltLOUEBxC7xs6lkFYzkHEgUDgl/1cHd2zzo5HINh8pdQkflQ+IqzhGYrRwQk4GZNPfX+gi6ZrnbK9qSwDxx7iSxRC2BKTIVgo5BS14XD2SpF8HGvpK5NYTymrYiPX1DeHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711564204; c=relaxed/simple; bh=HFIOmdmIrhYCPc1Z8mY+NlhIw+nPyRs2hNfCx5oOvEA=; h=Message-ID:Date:MIME-Version:Subject:From:To; b=GHl8XkgxgnJFNp9aWwZarU1ce2LU1OaRL7cNhmr+nqpZL2ttCzTC5GhSLH2IGNy6eC7rZ5nWwqj/IPV7mQr3OFuQpiWSHqz7vBOX3YKhmdaoY5U/FopkeM9Dx73wjeKbyHnT/Oq0Tp9UZjqpP5SBRcTULjD3N88A0C8S8ft6cN4= 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 505672F4; Wed, 27 Mar 2024 11:30:36 -0700 (PDT) Received: from [10.57.72.169] (unknown [10.57.72.169]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 637833F694; Wed, 27 Mar 2024 11:30:01 -0700 (PDT) Message-ID: <8d2380b8-4f62-42c8-b6ed-9c6021a4ef32@arm.com> Date: Wed, 27 Mar 2024 18:29:59 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCHv2 1/2] aarch64: Do not give ABI change diagnostics for _BitInt(N) From: "Andre Vieira (lists)" To: gcc-patches@gcc.gnu.org Cc: Richard.Sandiford@arm.com, Jakub@redhat.com, kyrylo.tkachov@arm.com References: <20240125174501.32634-1-andre.simoesdiasvieira@arm.com> Content-Language: en-US In-Reply-To: X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org This patch makes sure we do not give ABI change diagnostics for the ABI breaks of GCC 9, 13 and 14 for any type involving _BitInt(N), since that type did not exist before this GCC version. ChangeLog: * config/aarch64/aarch64.cc (bitint_or_aggr_of_bitint_p): New function. (aarch64_layout_arg): Don't emit diagnostics for types involving _BitInt(N). diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 1ea84c8bd7386e399f6ffa3a5e36408cf8831fc6..b68cf3e7cb9a6fa89b4e5826a39ffa11f64ca20a 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -6744,6 +6744,33 @@ aarch64_function_arg_alignment (machine_mode mode, const_tree type, return alignment; } +/* Return true if TYPE describes a _BitInt(N) or an angreggate that uses the + _BitInt(N) type. These include ARRAY_TYPE's with an element that is a + _BitInt(N) or an aggregate that uses it, and a RECORD_TYPE or a UNION_TYPE + with a field member that is a _BitInt(N) or an aggregate that uses it. + Return false otherwise. */ + +static bool +bitint_or_aggr_of_bitint_p (tree type) +{ + if (!type) + return false; + + if (TREE_CODE (type) == BITINT_TYPE) + return true; + + /* If ARRAY_TYPE, check it's element type. */ + if (TREE_CODE (type) == ARRAY_TYPE) + return bitint_or_aggr_of_bitint_p (TREE_TYPE (type)); + + /* If RECORD_TYPE or UNION_TYPE, check the fields' types. */ + if (RECORD_OR_UNION_TYPE_P (type)) + for (tree field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) + if (bitint_or_aggr_of_bitint_p (TREE_TYPE (field))) + return true; + return false; +} + /* Layout a function argument according to the AAPCS64 rules. The rule numbers refer to the rule numbers in the AAPCS64. ORIG_MODE is the mode that was originally given to us by the target hook, whereas the @@ -6767,12 +6794,6 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg) if (pcum->aapcs_arg_processed) return; - bool warn_pcs_change - = (warn_psabi - && !pcum->silent_p - && (currently_expanding_function_start - || currently_expanding_gimple_stmt)); - /* HFAs and HVAs can have an alignment greater than 16 bytes. For example: typedef struct foo { @@ -6907,6 +6928,18 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg) && (!alignment || abi_break_gcc_9 < alignment) && (!abi_break_gcc_13 || alignment < abi_break_gcc_13)); + + bool warn_pcs_change + = (warn_psabi + && !pcum->silent_p + && (currently_expanding_function_start + || currently_expanding_gimple_stmt) + /* warn_pcs_change is currently used to gate diagnostics in case of + abi_break_gcc_{9,13,14}. These however, do not apply to _BitInt(N) + types as they were only introduced in GCC 14. */ + && (!type || !bitint_or_aggr_of_bitint_p (type))); + + /* allocate_ncrn may be false-positive, but allocate_nvrn is quite reliable. The following code thus handles passing by SIMD/FP registers first. */ @@ -21266,19 +21299,25 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, rsize = ROUND_UP (size, UNITS_PER_WORD); nregs = rsize / UNITS_PER_WORD; - if (align <= 8 && abi_break_gcc_13 && warn_psabi) + if (align <= 8 + && abi_break_gcc_13 + && warn_psabi + && !bitint_or_aggr_of_bitint_p (type)) inform (input_location, "parameter passing for argument of type " "%qT changed in GCC 13.1", type); if (warn_psabi && abi_break_gcc_14 - && (abi_break_gcc_14 > 8 * BITS_PER_UNIT) != (align > 8)) + && (abi_break_gcc_14 > 8 * BITS_PER_UNIT) != (align > 8) + && !bitint_or_aggr_of_bitint_p (type)) inform (input_location, "parameter passing for argument of type " "%qT changed in GCC 14.1", type); if (align > 8) { - if (abi_break_gcc_9 && warn_psabi) + if (abi_break_gcc_9 + && warn_psabi + && !bitint_or_aggr_of_bitint_p (type)) inform (input_location, "parameter passing for argument of type " "%qT changed in GCC 9.1", type); dw_align = true;