From patchwork Wed Jan 10 12:22:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1884959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=u37YSbii; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=u37YSbii; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T96Qh6FYZz1xqk for ; Wed, 10 Jan 2024 23:23:24 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95B20385801A for ; Wed, 10 Jan 2024 12:23:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2087.outbound.protection.outlook.com [40.107.15.87]) by sourceware.org (Postfix) with ESMTPS id AF2003858C41 for ; Wed, 10 Jan 2024 12:22:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF2003858C41 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 AF2003858C41 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.87 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704889381; cv=pass; b=fNa0KuQJsgQwdrt6AMAyy3BQ3iBxNAGA7P0xzVLSJEWdZ/PdQawDJLP0qrcyHWpVQ4Zp9ohpgTbF08r1diY+vywZSAc5suzjY8kTyheYZad7jYgswIyN/r1fQW7/nJtgFkad9XDkVoD1FgxLicbKsv1Ghlcuw5X30O9Ps6WNbws= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704889381; c=relaxed/simple; bh=KfAE1Nq99anaHT0Pf3bF+fwuZUPzhLqj1ETpDoJYTa4=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=QpW7dRR2zys8a1Tig7z3npOXqvO1Amm+t96y/l6TbBaDi+PnhcTptsmIKUuu8qs2wtj3ZJtfkK4MVpU5oyibmbGybE4/L7NXqVvfM1LeWjpw21oDy22W+itMOMoeG4FIT6Wr0voPfgIJfr6QFf2p2g1Z9dB51FfEDhdH9BCt9b4= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=UZPEJuZxxRNIxqdwM0HXrLbWodkQdEao74j7GMmcEvXrMlLs1YYsY1cV/EFZECNRryyS47HUx8d5iFpPHuC+/mzdFj9aDn9Bitl/rWNCIh7fEtH/gAU6yaXJ2sU1PefDFbzJDvPJ309MqKKHCVr4yYlvrWBnDePCEg1xQzWuZMLpVlhbXoI3hhFN1mFZ4eypAo3eNGt4AGHyXIzcZ0m66nGcID6NVqWzbACYzUptfBttaYxNVDenceJIlp+hlk2ftVti6xmbRGvfSLzoJ+QzXcJwmJ+bpaKIh1TGt9qr2Pz9yS6C8EPqf9VewBzT0SonufZf6RcfJs93PCRpB+Dfog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LhmI7zVj7GEfnFxR2h7VYhsrShhpqRHuu//rwWYwWBs=; b=jq3uU9AbzAWrq5z6J/LNd4B76ICmydPISLbOTV1GWwtqv563uqX4Xey43AtIwFYUMOIpm88mo+ySD6C1vbV3xxvhpZHrzlUwJTSd4VLw9lR3/e2cvCjlBQaFJU0tEtdyrcbPdVmJfw/ocpuCb8wevPnoA3eoxFpT9w+E3PE0/S/ug+T8anqKP5mpm1EHCLSCVn9mND68pPFom6RTsUBM9C0zlzxvI4Z7GyZ+kC1qvwYA3Cb+LnnSDKmQUyn7C6ciMX1H2QZ0NdrsPXYX37p8F+2BO7NeUtVpF1ONOjDFK97t3txvF5zIglm7Wk5u6AgUMaxr7CYdl+PSg9wG9Tw+Fg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LhmI7zVj7GEfnFxR2h7VYhsrShhpqRHuu//rwWYwWBs=; b=u37YSbiit91GujtaTOkY/c+jqwnw38hPFbNNNADOD9jLADMVQ/DhxloCkkrq6mX2FOeHq8D7xu/mJoBO6cf1Tx/Q5+VWOpGJQgOG9z36CTmkBoSAkGhjlcmg0sJaNiR14qVYrcOvKlL/ftZ1ajV4ZpvlU9iitIadSniXVoWHTHU= Received: from AS9PR05CA0153.eurprd05.prod.outlook.com (2603:10a6:20b:496::10) by PR3PR08MB5564.eurprd08.prod.outlook.com (2603:10a6:102:87::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18; Wed, 10 Jan 2024 12:22:55 +0000 Received: from AM2PEPF0001C717.eurprd05.prod.outlook.com (2603:10a6:20b:496:cafe::be) by AS9PR05CA0153.outlook.office365.com (2603:10a6:20b:496::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23 via Frontend Transport; Wed, 10 Jan 2024 12:22:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM2PEPF0001C717.mail.protection.outlook.com (10.167.16.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.14 via Frontend Transport; Wed, 10 Jan 2024 12:22:55 +0000 Received: ("Tessian outbound 94d82ba85b1d:v228"); Wed, 10 Jan 2024 12:22:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 22b30c7b89fa97db X-CR-MTA-TID: 64aa7808 Received: from b63b0fae9fb9.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BD7BDBCC-3A2C-442E-8C32-E16DF9EA960C.1; Wed, 10 Jan 2024 12:22:48 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b63b0fae9fb9.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 10 Jan 2024 12:22:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lH/ARm43O5XyIJ+JQ8RG5oFT07ac+nKvzVqIDKllOjC5XEYPP6pEDk8pfCQPo/0Xyf/isOqwO7pisQY826Lk2s91urBQe/MznDJxCOr/EqsBtIUnHAqbpZBDPDl9PfOnIbOd1gzFN9A25Mq6nIplisH6n/RT7uhsEpR5HkGbzuCFBi/BwYRFYZQdiXcY8C3EVcW7fYNdKyGa/WoxYFsatHrGM/edW/U9xtMkIK6a13BNG5Bs6F4w8fgEohA0HKcwmxxKBMR+q3ULwhdX4E+mM8tUs9ls0ttPOsX1Liq+qNm4E+Ti95Fw1vA5dIViTP8Fy1r/ZAHu4ODXIZMsra2YZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LhmI7zVj7GEfnFxR2h7VYhsrShhpqRHuu//rwWYwWBs=; b=oWc8wqAvINtlnrDg95QI3TO9ck435xa0r7cOTgL89w4D5kFCOSF3biOZAvpa9VXjL2YpkZOeiZ4BWgJ+stBpZfP560t15DbvtbWo2lrT68M5LIjTvJv1J9b8f1Wc30ZHCg/WBOb74cpP1reB9/zuexV/pdKx6SMjY6vLh31spL7YdGXG4B0IInBeHJ5etolA+CEKLEd9cwCNtFnvEa0iPxZX3siC6cMu3WDCvafE1KpubM2JJGIcK9cRXjHoLSwDY+B/EAv3YG3y3yzLlU6ob3Yw1HyU69u2JpyHFnjmJckQ9UAQ2YEqTUMB4NScaasK9/jZJTm2r8WK4snVWW6bVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LhmI7zVj7GEfnFxR2h7VYhsrShhpqRHuu//rwWYwWBs=; b=u37YSbiit91GujtaTOkY/c+jqwnw38hPFbNNNADOD9jLADMVQ/DhxloCkkrq6mX2FOeHq8D7xu/mJoBO6cf1Tx/Q5+VWOpGJQgOG9z36CTmkBoSAkGhjlcmg0sJaNiR14qVYrcOvKlL/ftZ1ajV4ZpvlU9iitIadSniXVoWHTHU= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by AS8PR08MB8874.eurprd08.prod.outlook.com (2603:10a6:20b:5b8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17; Wed, 10 Jan 2024 12:22:46 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::48ca:fbcb:84bf:ed17%4]) with mapi id 15.20.7181.015; Wed, 10 Jan 2024 12:22:46 +0000 Date: Wed, 10 Jan 2024 12:22:44 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH v2] aarch64: Fix dwarf2cfi ICEs due to recent CFI note changes [PR113077] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P123CA0124.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::21) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|AS8PR08MB8874:EE_|AM2PEPF0001C717:EE_|PR3PR08MB5564:EE_ X-MS-Office365-Filtering-Correlation-Id: d75cf205-59dc-4a39-7d5f-08dc11d6dfd5 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 8hE++FNx1NY5YIB24x8ehU+RENgh1+t7us6YmLsRTOgmaPjZh4zZEptsdmYsmVJxj/YFJRfPrhstjmaQdzb2J7a2L8kJe3NJYOKDYBOY7SbekQZvZgtdYktordCYSFBv7IDIf/kzU+CUn829ZWGtsrUTrkR1lM8vACLm2Nw1wBCFTMxi+6VDdUOVYqCUNlZNu6wKUuqxLpWh8hJJdMD7v5JZNu+PFlhxpuqg4lkCl8vX3omB2AuqbjhEUz6viDEYMDfF8czS8d4AVfep8LjyD6YLaqGbIbcpGpLxbHXAk/pOXYCX9ymNU4/6hp5+wRDfgcFxFUZtp6uTj/N6DEynLrinZY5f76ZWVARqH6+x48biYkDNFfEwT6IhHM5X/ZgLXENVW3nIj4WePoU4eFRhct8SHg9xOcO2dSgSOBplEVGATZ6Bgw13fbk6lFHMzfcHQu8Ag+aj9aweiVO6AteHv7e8cE+FbCZt4M5IuMLlZ6BJz0WpzQpaBOby2j9/0oFL9cgF9HEYcuyhq2Ntu/uQ4El1jmQ5NGInWm/usYks+oBqIG5xfsbtVudknsILLJpBJdeVhuJQdJszsE9habMPg2FBxXxms3ixS3hcQCxexXAA28/snn5E1HGzNXA3GLlXo9S6rC1/tsN4HVfiQzoJOQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAWPR08MB8958.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(396003)(366004)(346002)(39860400002)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(44144004)(8936002)(8676002)(478600001)(966005)(6512007)(84970400001)(6506007)(316002)(66946007)(6916009)(66476007)(66556008)(33964004)(235185007)(83380400001)(6486002)(44832011)(4326008)(26005)(38100700002)(36756003)(2906002)(5660300002)(21480400003)(2616005)(41300700001)(86362001)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8874 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM2PEPF0001C717.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1293c7cd-1591-4d2f-3334-08dc11d6da47 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lexmgMYDrVDhfsxBEwbkH7OZrZJ2E4lzP1M4xwcuaACVk8EK7DE7WsA/wPCTu2M5yTUKUFnI3Kcxz7/+GpWuj3666ILIV2fRYrIWU4pGx9+jX8ClVJZCxPQAVIJwAhnkUWlCNmN7QrqY8kKV0PhPPpzF+9OMrMvNUys1kQD7eqIUaOUJlnI37XCAvCTDJTjzAOxWDzfMfRfixgq9Wzd/qyRx26RpDx2WmRw/r9mCy2IV4+AEAOBoonaLqdUat9wFaTYoCMw6TP6/OB5kjCc4mySTvH065ijSoC1LVXuFk2KGch1hTOl0lBMfHWwy9m6Ig2624bqi7X/Hg/XNfW3emMZRoXw9CaLzANJHwxfNmGF5eKLqF8gLOUFQ9tDhYeGBAzfL82HNfELRRYBN75zp0R1JXOsJhmZXsm7C0pnpxO7LhPTXK9w2vFOLpi7BzPqblcsxvRau+9Fi6vFp6oZ76G+KTkUaEkqV6vODxa3SUwmz05C0zxsYe2m/ZSAOQEYT/ithl8z6Akn4ucKM1+tNXQx64wlKX89hBQ7UBVyEBAva3L8FVTue+Ow0JjrNhQhvmYh34a2+jQ+dmhRG5T5T1NOk3219oYB00OGGRuMUm4EfTnwJ8aLK9VmIkvf0h74Pp41EPzkOy6G7jK4ENTJN0EfqRD/kS8fZeiXesCGu619DVytRa/EoMzompEjCqxiQdBAHefHEZsCgsHTlQDts039/NyMsOz0f2kJamYwkwpa7V1GSre72K1o7d9r5qn1JQTow4XYroEBlZ4MSSOTBDZzsdTAVagvVwIdf+3hTRv8= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(376002)(396003)(346002)(230922051799003)(64100799003)(451199024)(186009)(82310400011)(1800799012)(46966006)(36840700001)(40470700004)(83380400001)(21480400003)(6512007)(336012)(2616005)(82740400003)(26005)(47076005)(36860700001)(44832011)(4326008)(8676002)(5660300002)(235185007)(2906002)(966005)(6486002)(6916009)(33964004)(44144004)(478600001)(6506007)(8936002)(70206006)(316002)(70586007)(41300700001)(356005)(81166007)(36756003)(86362001)(40480700001)(84970400001)(40460700003)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 12:22:55.4970 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d75cf205-59dc-4a39-7d5f-08dc11d6dfd5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C717.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5564 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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+incoming=patchwork.ozlabs.org@gcc.gnu.org This is a v2 which addresses feedback from v1, posted here: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642313.html Bootstrapped/regtested on aarch64-linux-gnu, OK for trunk? Thanks, Alex -- >8 -- In r14-6604-gd7ee988c491cde43d04fe25f2b3dbad9d85ded45 we changed the CFI notes attached to callee saves (in aarch64_save_callee_saves). That patch changed the ldp/stp representation to use unspecs instead of PARALLEL moves. This meant that we needed to attach CFI notes to all frame-related pair saves such that dwarf2cfi could still emit the appropriate CFI (it cannot interpret the unspecs directly). The patch also attached REG_CFA_OFFSET notes to individual saves so that the ldp/stp pass could easily preserve them when forming stps. In that change I chose to use REG_CFA_OFFSET, but as the PR shows, that choice was problematic in that REG_CFA_OFFSET requires the attached store to be expressed in terms of the current CFA register at all times. This means that even scheduling of frame-related insns can break this invariant, leading to ICEs in dwarf2cfi. The old behaviour (before that change) allowed dwarf2cfi to interpret the RTL directly for sp-relative saves. This change restores that behaviour by using REG_FRAME_RELATED_EXPR instead of REG_CFA_OFFSET. REG_FRAME_RELATED_EXPR effectively just gives a different pattern for dwarf2cfi to look at instead of the main insn pattern. That allows us to attach the old-style PARALLEL move representation in a REG_FRAME_RELATED_EXPR note and means we are free to always express the save addresses in terms of the stack pointer. Since the ldp/stp fusion pass can combine frame-related stores, this patch also updates it to preserve REG_FRAME_RELATED_EXPR notes, and additionally gives it the ability to synthesize those notes when combining sp-relative saves into an stp (the latter always needs a note due to the unspec representation, the former does not). gcc/ChangeLog: PR target/113077 * config/aarch64/aarch64-ldp-fusion.cc (filter_notes): Add fr_expr param to extract REG_FRAME_RELATED_EXPR notes. (combine_reg_notes): Handle REG_FRAME_RELATED_EXPR notes, and synthesize these if needed. Update caller ... (ldp_bb_info::fuse_pair): ... here. * config/aarch64/aarch64.cc (aarch64_save_callee_saves): Use REG_FRAME_RELATED_EXPR instead of REG_CFA_OFFSET. gcc/testsuite/ChangeLog: PR target/113077 * gcc.target/aarch64/pr113077.c: New test. diff --git a/gcc/config/aarch64/aarch64-ldp-fusion.cc b/gcc/config/aarch64/aarch64-ldp-fusion.cc index 2fe1b1d4d84..324d28797da 100644 --- a/gcc/config/aarch64/aarch64-ldp-fusion.cc +++ b/gcc/config/aarch64/aarch64-ldp-fusion.cc @@ -904,9 +904,11 @@ aarch64_operand_mode_for_pair_mode (machine_mode mode) // Go through the reg notes rooted at NOTE, dropping those that we should drop, // and preserving those that we want to keep by prepending them to (and // returning) RESULT. EH_REGION is used to make sure we have at most one -// REG_EH_REGION note in the resulting list. +// REG_EH_REGION note in the resulting list. FR_EXPR is used to return any +// REG_FRAME_RELATED_EXPR note we find, as these can need special handling in +// combine_reg_notes. static rtx -filter_notes (rtx note, rtx result, bool *eh_region) +filter_notes (rtx note, rtx result, bool *eh_region, rtx *fr_expr) { for (; note; note = XEXP (note, 1)) { @@ -940,6 +942,10 @@ filter_notes (rtx note, rtx result, bool *eh_region) copy_rtx (XEXP (note, 0)), result); break; + case REG_FRAME_RELATED_EXPR: + gcc_assert (!*fr_expr); + *fr_expr = copy_rtx (XEXP (note, 0)); + break; default: // Unexpected REG_NOTE kind. gcc_unreachable (); @@ -951,13 +957,52 @@ filter_notes (rtx note, rtx result, bool *eh_region) // Return the notes that should be attached to a combination of I1 and I2, where // *I1 < *I2. +// +// LOAD_P is true for loads, REVERSED is true if the insns in program order are +// not in offset order, and PATS gives the final RTL patterns for the accesses. static rtx -combine_reg_notes (insn_info *i1, insn_info *i2) +combine_reg_notes (insn_info *i1, insn_info *i2, bool load_p, bool reversed, + rtx pats[2]) { + // Temporary storage for REG_FRAME_RELATED_EXPR notes. + rtx fr_expr[2] = {}; + bool found_eh_region = false; rtx result = NULL_RTX; - result = filter_notes (REG_NOTES (i2->rtl ()), result, &found_eh_region); - return filter_notes (REG_NOTES (i1->rtl ()), result, &found_eh_region); + result = filter_notes (REG_NOTES (i2->rtl ()), result, + &found_eh_region, fr_expr); + result = filter_notes (REG_NOTES (i1->rtl ()), result, + &found_eh_region, fr_expr + 1); + + if (!load_p) + { + // Simple frame-related sp-relative saves don't need CFI notes, but when + // we combine them into an stp we will need a CFI note as dwarf2cfi can't + // interpret the unspec pair representation directly. + if (RTX_FRAME_RELATED_P (i1->rtl ()) && !fr_expr[0]) + fr_expr[0] = copy_rtx (pats[reversed]); + if (RTX_FRAME_RELATED_P (i2->rtl ()) && !fr_expr[1]) + fr_expr[1] = copy_rtx (pats[!reversed]); + } + + rtx fr_pat = NULL_RTX; + if (fr_expr[0] && fr_expr[1]) + { + // Combining two frame-related insns, need to construct + // a REG_FRAME_RELATED_EXPR note which represents the combined + // operation. + RTX_FRAME_RELATED_P (fr_expr[1]) = 1; + fr_pat = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, fr_expr[0], fr_expr[1])); + } + else + fr_pat = fr_expr[0] ? fr_expr[0] : fr_expr[1]; + + if (fr_pat) + result = alloc_reg_note (REG_FRAME_RELATED_EXPR, + fr_pat, result); + + return result; } // Given two memory accesses in PATS, at least one of which is of a @@ -1380,7 +1425,7 @@ ldp_bb_info::fuse_pair (bool load_p, return false; } - rtx reg_notes = combine_reg_notes (first, second); + rtx reg_notes = combine_reg_notes (first, second, load_p, i1 != first, pats); rtx pair_pat; if (writeback_effect) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index a5a6b52730d..1a543e6c87f 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -8465,7 +8465,7 @@ aarch64_save_callee_saves (poly_int64 bytes_below_sp, emit_move_insn (move_src, gen_int_mode (aarch64_sve_vg, DImode)); } rtx base_rtx = stack_pointer_rtx; - poly_int64 cfa_offset = offset; + poly_int64 sp_offset = offset; HOST_WIDE_INT const_offset; if (mode == VNx2DImode && BYTES_BIG_ENDIAN) @@ -8490,17 +8490,12 @@ aarch64_save_callee_saves (poly_int64 bytes_below_sp, offset -= fp_offset; } rtx mem = gen_frame_mem (mode, plus_constant (Pmode, base_rtx, offset)); + rtx cfi_mem = gen_frame_mem (mode, plus_constant (Pmode, + stack_pointer_rtx, + sp_offset)); + rtx cfi_set = gen_rtx_SET (cfi_mem, reg); + bool need_cfi_note_p = (base_rtx != stack_pointer_rtx); - rtx cfa_base = stack_pointer_rtx; - if (hard_fp_valid_p && frame_pointer_needed) - { - cfa_base = hard_frame_pointer_rtx; - cfa_offset += (bytes_below_sp - frame.bytes_below_hard_fp); - } - - rtx cfa_mem = gen_frame_mem (mode, - plus_constant (Pmode, - cfa_base, cfa_offset)); unsigned int regno2; if (!aarch64_sve_mode_p (mode) && reg == move_src @@ -8514,34 +8509,47 @@ aarch64_save_callee_saves (poly_int64 bytes_below_sp, offset += GET_MODE_SIZE (mode); insn = emit_insn (aarch64_gen_store_pair (mem, reg, reg2)); - /* The first part of a frame-related parallel insn is - always assumed to be relevant to the frame - calculations; subsequent parts, are only - frame-related if explicitly marked. */ + rtx cfi_mem2 + = gen_frame_mem (mode, + plus_constant (Pmode, + stack_pointer_rtx, + sp_offset + GET_MODE_SIZE (mode))); + rtx cfi_set2 = gen_rtx_SET (cfi_mem2, reg2); + + /* The first part of a frame-related parallel insn is always + assumed to be relevant to the frame calculations; + subsequent parts, are only frame-related if + explicitly marked. */ if (aarch64_emit_cfi_for_reg_p (regno2)) - { - const auto off = cfa_offset + GET_MODE_SIZE (mode); - rtx cfa_mem2 = gen_frame_mem (mode, - plus_constant (Pmode, - cfa_base, - off)); - add_reg_note (insn, REG_CFA_OFFSET, - gen_rtx_SET (cfa_mem2, reg2)); - } + RTX_FRAME_RELATED_P (cfi_set2) = 1; + + /* Add a REG_FRAME_RELATED_EXPR note since the unspec + representation of stp cannot be understood directly by + dwarf2cfi. */ + rtx par = gen_rtx_PARALLEL (VOIDmode, + gen_rtvec (2, cfi_set, cfi_set2)); + add_reg_note (insn, REG_FRAME_RELATED_EXPR, par); regno = regno2; ++i; } - else if (mode == VNx2DImode && BYTES_BIG_ENDIAN) - insn = emit_insn (gen_aarch64_pred_mov (mode, mem, ptrue, move_src)); - else if (aarch64_sve_mode_p (mode)) - insn = emit_insn (gen_rtx_SET (mem, move_src)); else - insn = emit_move_insn (mem, move_src); + { + if (mode == VNx2DImode && BYTES_BIG_ENDIAN) + { + insn = emit_insn (gen_aarch64_pred_mov (mode, mem, ptrue, move_src)); + need_cfi_note_p = true; + } + else if (aarch64_sve_mode_p (mode)) + insn = emit_insn (gen_rtx_SET (mem, move_src)); + else + insn = emit_move_insn (mem, move_src); + + if (frame_related_p && (need_cfi_note_p || move_src != reg)) + add_reg_note (insn, REG_FRAME_RELATED_EXPR, cfi_set); + } RTX_FRAME_RELATED_P (insn) = frame_related_p; - if (frame_related_p) - add_reg_note (insn, REG_CFA_OFFSET, gen_rtx_SET (cfa_mem, reg)); /* Emit a fake instruction to indicate that the VG save slot has been initialized. */ diff --git a/gcc/testsuite/gcc.target/aarch64/pr113077.c b/gcc/testsuite/gcc.target/aarch64/pr113077.c new file mode 100644 index 00000000000..dca202bd2ba --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr113077.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O2 -fstack-protector-strong -fstack-clash-protection" } */ +void add_key(const void *payload); +void act_keyctl_test(void) { + char buf[1030 * 1024]; + int i = 0; + for (i = 0; i < sizeof(buf); i++) + { + add_key(buf); + } +}