From patchwork Tue Mar 29 16:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Earnshaw X-Patchwork-Id: 52452 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 5CF253857C49 for ; Tue, 29 Mar 2022 16:05:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CF253857C49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648569924; bh=yHqmLlQPaWHznCIuhZqwaA4PPx7fNhQK/LUTgqAtv/0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Nv/RGBdYB6C9jtzNs5FEESUE0Xu/hoKG6eOM0Rl5OYimZY7oVii8NoTf+OddqoIsB quDwJVM7sCoONAWUWBkgQNs6LzucioCmlFEPhIRfP3MFbcPrnith7aym68UMxiAll/ czurIQLmyi/SbUJYsfgO8L1TKeUlHYc/bjaAayis= 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 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) To: gcc-patches@gcc.gnu.org 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 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-Patchwork-Original-From: Richard Earnshaw via Gcc-patches From: Richard Earnshaw Reply-To: Richard Earnshaw Cc: Richard Earnshaw Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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(-) 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");