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 A473D3858C50 for ; Tue, 29 Mar 2022 16:04:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A473D3858C50 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 4C9BA23A; Tue, 29 Mar 2022 09:04:55 -0700 (PDT) Received: from e126323.arm.com (unknown [10.57.40.209]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8E8AA3F73B; Tue, 29 Mar 2022 09:04:54 -0700 (PDT) From: Richard Earnshaw To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw Subject: [committed] arm: temporarily disable 'local' pcs selection (PR96882) Date: Tue, 29 Mar 2022 17:04:41 +0100 Message-Id: <20220329160441.125782-1-rearnsha@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.25.1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 16:04:57 -0000 This is a multi-part message in MIME format. --------------2.25.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit The arm port has an optimization used during selection of the function's ABI to permit deviation from the strict ABI when the function does not escape the current translation unit. Unfortunately, the ABI selection it makes can be unsafe if it changes how a result is returned because not enough information is available via the RETURN_IN_MEMORY hook to determine where the function gets used. This can result in some parts of the compiler thinking a value is returned in memory while others think it is returned in registers. To mitigate this, this patch temporarily disables the optimization and falls back to using the default ABI for the translation. gcc/ChangeLog: PR target/96882 * config/arm/arm.cc (arm_get_pcs_model): Disable selection of ARM_PCS_AAPCS_LOCAL. --- gcc/config/arm/arm.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --------------2.25.1 Content-Type: text/x-patch; name="0001-arm-temporarily-disable-local-pcs-selection-PR96882.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-arm-temporarily-disable-local-pcs-selection-PR96882.patch" diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index e062361b985..26ed7f97fc6 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -6194,7 +6194,7 @@ arm_pcs_from_attribute (tree attr) specification, DECL is the specific declartion. DECL may be null if the call could be indirect or if this is a library call. */ static enum arm_pcs -arm_get_pcs_model (const_tree type, const_tree decl) +arm_get_pcs_model (const_tree type, const_tree decl ATTRIBUTE_UNUSED) { bool user_convention = false; enum arm_pcs user_pcs = arm_pcs_default; @@ -6228,6 +6228,14 @@ arm_get_pcs_model (const_tree type, const_tree decl) return ARM_PCS_AAPCS; else if (user_convention) return user_pcs; +#if 0 + /* Unfortunately, this is not safe and can lead to wrong code + being generated (PR96882). Not all calls into the back-end + pass the DECL, so it is unsafe to make any PCS-changing + decisions based on it. In particular the RETURN_IN_MEMORY + hook is only ever passed a TYPE. This needs revisiting to + see if there are any partial improvements that can be + re-enabled. */ else if (decl && flag_unit_at_a_time) { /* Local functions never leak outside this compilation unit, @@ -6239,6 +6247,7 @@ arm_get_pcs_model (const_tree type, const_tree decl) if (local_info_node && local_info_node->local) return ARM_PCS_AAPCS_LOCAL; } +#endif } else if (user_convention && user_pcs != arm_pcs_default) sorry ("PCS variant"); --------------2.25.1--