From patchwork Wed Jan 10 21:11:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1885175 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=VuiDcIUz; 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=VuiDcIUz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4T9L8T1TmFz1yPp for ; Thu, 11 Jan 2024 08:11:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A7B03858004 for ; Wed, 10 Jan 2024 21:11:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by sourceware.org (Postfix) with ESMTPS id 13E9C3858D38 for ; Wed, 10 Jan 2024 21:11:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13E9C3858D38 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 13E9C3858D38 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.7.81 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704921084; cv=pass; b=ENsopCN90KGfzcDkjyAq4+l2eoUivxj1m6JgfQEdKim7vNZHVkOytRyxaua0NtkSNET/sQhKY2ona1mv/cPcJX1VOxh8HMDf1h1KhQ5U6VyZHET1/V/EfWGDrPElA3K6ssSqSWEYn+yo51zswtLSD7icg++HEoVanSQnwYCsccA= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704921084; c=relaxed/simple; bh=BkCjZwDIC73BrOqxFsdGckujbgfu6igdcPMOsBNVxTo=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=qIx6JEktTCOvJE96rx7HfouYFwoi7TyIjU+/yxgh64rs9X1IKVUazfU4O/QKHbwZUWrzoBlllApHxzukvuOqUm7B38yC566WL5eeOjOKiMVzGWQBSY8IWDJdbLour1dCIw6mB60eyyKJU8XcbxhpzDYMZqTM6+qD9TlEbjJ1TMM= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=LwmT7NoclTspfC7lfmQppBqkuJpImim9soOv7Rt6kGjSGfqEhYXi7attU/Gp40p5oId7ERYzf5HhJh8obkddS5xldv7XX6v7XUoUKO6cJYOip8mxoR62zegFIqKg92OZhaLRXomg9T2ogr2C3+HDxFsxlpdw/wrMtzF74KgyNGblyHrApWILrmZEKE2sfMzf/EkHwHoHnoZkxUSx7yO32otpozwz7heR+G2WcKWj5t0twaF8qM8413ECm+vu6s4IjxaWxlIFG78/2+hJcnU8BupI2ED5yaRXunIqtizCpaSPTe0SycVKQ16vfuFRZ+vecmKD5ipZdG/R07GRxOz2BA== 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=9XFn3sXZ2RC+vOREHBDMJaPn6ylchrKfHYDfoPkKyVs=; b=PUSI7muEM0axqyUifuGroghKQy3tjbTA/DeOBe3y8kd15e0pgK50Cx2/gz/snTpGQwW9EKx597MpKM7RvZ1m0il4Jjilno4lKSImP/2QKBEkJjpVlcabH3rs2pOlWUHMkJF/KkxbOWyOR2ckOKspDEclyGS9uDkLHp98A+RNfR63cc9sQ3w9lO5bRh2NNazOAJocMQDitGzrsRtJbTBDmKgg/fB5Si99uLwA3B7qu8dJGpej+/wCtJrUkBfZiYD0gOwhqj/9+tTdLN+jDLtAuv4HhrUB9+qZj22vFVM1F3tNpXH579XL5m98d86zhrvshuCNnAKViBo8P9JOyWToOw== 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=9XFn3sXZ2RC+vOREHBDMJaPn6ylchrKfHYDfoPkKyVs=; b=VuiDcIUzNqo2r7vP6MQqCD4I/HP7HSwsK516XeZmFxIRJLldXsvM2QbQcW54Cg2COaAlf48zn54TGkekUC7y2S0X5FVgga1hBvWWt6lrrLg5aEHU27dX1MQmFQwuNNxyPlL95awJErJl/Up+AkPl3IcMK11Bq9S6nkkJMXK00ns= Received: from AS9PR05CA0326.eurprd05.prod.outlook.com (2603:10a6:20b:491::23) by AS8PR08MB9600.eurprd08.prod.outlook.com (2603:10a6:20b:618::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Wed, 10 Jan 2024 21:11:19 +0000 Received: from AMS0EPF000001AF.eurprd05.prod.outlook.com (2603:10a6:20b:491:cafe::59) by AS9PR05CA0326.outlook.office365.com (2603:10a6:20b:491::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17 via Frontend Transport; Wed, 10 Jan 2024 21:11:19 +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 AMS0EPF000001AF.mail.protection.outlook.com (10.167.16.155) 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 21:11:19 +0000 Received: ("Tessian outbound 1076c872ecc6:v228"); Wed, 10 Jan 2024 21:11:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dc2e35a6b383fcef X-CR-MTA-TID: 64aa7808 Received: from c4d167423b76.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 84F69DC3-4751-440D-B5BE-6577D53ABAE3.1; Wed, 10 Jan 2024 21:11:12 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c4d167423b76.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 10 Jan 2024 21:11:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GnGV/MqFGlBLjo9KtSn1p6TlvLInDzFMH12MM0ALDASC43Hglr8oR4S0/URvR5CxE6bBwbk1nYf+wUvSOGbuS2TSOcoqHfX/gGnPubeaFByXt30+rqi2E18To4Y8XWKBp7egDDkgAQTXGP5JCMxAPM8nsI7TXXonk2lCi3jDi4s4nX5ACicpkerjBHLb1teDhPrOrzCiTbje995cokfbyAZ+C3AxZJoZW+rJlrU2X4oTEUMp6D6OwmrGsoMg+uPKDL7qcF/xHO6B+N0NjVRiGks3B0RwXlkdiW0SoC7vuIh7wycFP/YKVUKeVY7Gr4SwF45pwv5766DZcpZ3Jf5rGQ== 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=9XFn3sXZ2RC+vOREHBDMJaPn6ylchrKfHYDfoPkKyVs=; b=hKees0sUOV9e+xzJRAdkc7N0a3hxa9hXkd/Gbs63DjE5nD7gnxfz4O40XwDP/HWTv9FnDjMNFtTurCy1JN8QRAykWXwbRqVWBGYzsWqSp6yPf0d7hf25/G7sOlLfwwCL1kTprvgAl62lA7ucOCT8SH4e55HIx2XjolJ9GE5YwRXSYn9W2nRDyMhvHVjgfJB2Bm+a0EflrmknQlaXRblbCKvxtuNzhYEzMv00ltCbIhjHQoePnY2l7Obh6kqmLd8MYIcWODbMjP08bM0RJZuG+D5oRVqtc5ady5x54nS7F0ZD4zaetOypfGfGdd+awaFc0KhFfZlfn91DZ2m6aXhLVg== 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=9XFn3sXZ2RC+vOREHBDMJaPn6ylchrKfHYDfoPkKyVs=; b=VuiDcIUzNqo2r7vP6MQqCD4I/HP7HSwsK516XeZmFxIRJLldXsvM2QbQcW54Cg2COaAlf48zn54TGkekUC7y2S0X5FVgga1hBvWWt6lrrLg5aEHU27dX1MQmFQwuNNxyPlL95awJErJl/Up+AkPl3IcMK11Bq9S6nkkJMXK00ns= 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 VE1PR08MB5613.eurprd08.prod.outlook.com (2603:10a6:800:1a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Wed, 10 Jan 2024 21:11:07 +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 21:11:07 +0000 Date: Wed, 10 Jan 2024 21:11:04 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw , Richard Sandiford , Kyrylo Tkachov Subject: [PATCH v3] aarch64: Fix dwarf2cfi ICEs due to recent CFI note changes [PR113077] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LO4P265CA0006.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ad::20) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|VE1PR08MB5613:EE_|AMS0EPF000001AF:EE_|AS8PR08MB9600:EE_ X-MS-Office365-Filtering-Correlation-Id: 587003c3-93a3-46d0-243f-08dc1220b0af 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: W2r5PZ2cgVRvO/g6jRgH36dggwUWrXcvMH2GEG3MThHYFbxET3q2OQy2FoxAIdpjgfdkNoFz+Ne9sHMP0EovWbk263jmChk8GdTXKBr47u2s606QxcNEBAanAXvkp57j24oI610b8d9l5WlXSNAYcG5tqQUHmoTAGZcItVijboz98PqUxHVdDEHBhr4JZynv5Qdq8jRCj7KfZXlGVe5tdVcT6ETFsF1fTfW8JlbJXsant7CMwSPqkBZhyqZKz2o+C1pZgHaW1PSXFzq/pKwzaaRLVgIjPE7rH2nbV+PKZbVK9OaWaAWRUjkr+oHnIGADhJlf8DRiEbni6qFOQRLbCLN9i6nqdpBmVtYJBMek7lhHNliWet0jsL+m1DpeuCfgM+bYXi1u7+4weK0rMsbcZAcwyb5jv+qVR2LjWfP3F0M+Oy2otnzrhE2c0n0XaBc4gwXBi7YS3H1HEy6f/ZNguWuBPMqMNqhZgI0VVF3yh05QPUZCFnAyVLqj0ZvZi7gintSKE35DsBWdnb0JR3CP/eMwZjqj7pvUZcIWKogZ5h5p+POj3un2DSlVgNIzaAqodYAg0w7dC3PlS3uWh4WhdMcYggPXZcuaa6AoJMz8o1o= 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)(39850400004)(366004)(396003)(346002)(376002)(136003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(84970400001)(83380400001)(41300700001)(86362001)(36756003)(66946007)(38100700002)(966005)(66476007)(26005)(21480400003)(2616005)(6512007)(6506007)(6666004)(33964004)(6486002)(66556008)(54906003)(6916009)(2906002)(316002)(44144004)(478600001)(8676002)(44832011)(8936002)(4326008)(5660300002)(235185007)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5613 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: AMS0EPF000001AF.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 8a058485-1fed-4c88-f65a-08dc1220a948 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PUKZhPd+YSCg1h285Bu971gH2GypxhxkCvpxFXbiPOlFUeLxTmunT3Cp7IjbCFN/5tIDXTz2yvEE1J1coCN/TzGAcrUHtcchKhdymMER3jlVijfam2OChErCRTfoNgdU6qdIVJ6pGRs3TjsjLGOrmOnpNiS7RBT2iWWU89C45rux8lcFr4627xbZxWFUv51kjpgy1PgYb8mrZYKc1obCgXAMHe1rTQvCG2OVh5RA6ha5+1fZ6NkdoZgIoReVDcpf0oKRwLDz7b00+wEOPbhT5umw1xxgC79xzFI33zAbc5UPvWRUqI6VfX1wd0f79nkCOMbgTmeupvjYdhD8IB9bozr4Axx5xnRilpbiTVhq1+6f6W4/MxrovxPBhv+DuC3pK0u7PItPehjPTDLGEasbwIEuWXDDFgPlALYC8hEWoL1YI7vphJaWdw6L96O2U9oOY2xDZWfg/8gOhe31EAiKWIMNvf1AoqAaTJe9aPymhveZWTjNN1xS5FCrDL4aJx4JLgMuZC7wl3IpTxAsyKTRAPaAWhi/ZTC4UWT/WTdj72r/LSJFg9MJkBgaIMHpuRKC4eXniPwiL9KljK59ncrlSoUQ+AgHuCw6Xq59f3EJTDuGxeq45ORh6AsXKOHW0T4YUvT7WjKmCywE2yOWbXuYyZT8+zvLCEyFZmQn8y72OtksllgNrwaG7pDZHEO+TddC8W1Pkojbj25e5ttV8+P3CpysSvV65pntCn7JyQA4kicIPc6pHz5bP2lT+KT5/AF3RYt73OR4d6/9JeYsaV0ryLRZ0nQgLwi6XkAR+DTNXFI= 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)(376002)(346002)(39860400002)(396003)(136003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(84970400001)(40480700001)(40460700003)(83380400001)(86362001)(70206006)(70586007)(41300700001)(356005)(36756003)(81166007)(54906003)(82740400003)(47076005)(36860700001)(21480400003)(336012)(2616005)(6512007)(26005)(5660300002)(6916009)(2906002)(6486002)(44144004)(6506007)(316002)(33964004)(44832011)(6666004)(478600001)(235185007)(4326008)(8676002)(8936002)(966005)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2024 21:11:19.1664 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 587003c3-93a3-46d0-243f-08dc1220b0af 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: AMS0EPF000001AF.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9600 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 v3 which addresses shortcomings of the v2 patch. v2 was posted here: https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642448.html The main issue in v2 is that we were using the final (transformed) patterns in combine_reg_notes instead of the initial patterns (thanks Richard S for pointing that out off-list). For frame-related insns, it seems better to use the initial patterns, as we may have changed base away from the stack pointer, but any frame-related single stores without a CFI note should initially have the stack pointer as a base (and we want the CFI notes to be expressed in terms of the stack pointer, even if we changed the base for the stp). So that we don't have to worry about the writeback case (which seems unlikely to ever happen anyway for frame-related insns) we punt on pairs where there is any writeback together with a frame-related insn, and also punt in find_trailing_add if either of the insns are frame-related. I considered punting on frame-related insns altogether but it is useful (at least) for the pass to merge SVE vector saves with -msve-vector-bits=128. Bootstrapped/regtested on aarch64-linux-gnu with/without the ldp/stp passes enabled, 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. (ldp_bb_info::try_fuse_pair): Punt if either insn has writeback and either insn is frame-related. (find_trailing_add): Punt on frame-related insns. * 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..689a8c884bd 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 (); @@ -950,14 +956,49 @@ 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. +// *I1 < *I2. LOAD_P is true for loads. static rtx -combine_reg_notes (insn_info *i1, insn_info *i2) +combine_reg_notes (insn_info *i1, insn_info *i2, bool load_p) { + // 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 (PATTERN (i1->rtl ())); + if (RTX_FRAME_RELATED_P (i2->rtl ()) && !fr_expr[1]) + fr_expr[1] = copy_rtx (PATTERN (i2->rtl ())); + } + + 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 @@ -1049,6 +1090,14 @@ find_trailing_add (insn_info *insns[2], poly_int64 initial_offset, unsigned access_size) { + // Punt on frame-related insns, it is better to be conservative and + // not try to form writeback pairs here, and means we don't have to + // worry about the writeback case in forming REG_FRAME_RELATED_EXPR + // notes (see combine_reg_notes). + if ((insns[0] && RTX_FRAME_RELATED_P (insns[0]->rtl ())) + || RTX_FRAME_RELATED_P (insns[1]->rtl ())) + return nullptr; + insn_info *pair_dst = pair_range.singleton (); gcc_assert (pair_dst); @@ -1380,7 +1429,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); rtx pair_pat; if (writeback_effect) @@ -1987,6 +2036,19 @@ ldp_bb_info::try_fuse_pair (bool load_p, unsigned access_size, return false; } + // Punt on frame-related insns with writeback. We probably won't see + // these in practice, but this is conservative and ensures we don't + // have to worry about these later on. + if (writeback && (RTX_FRAME_RELATED_P (i1->rtl ()) + || RTX_FRAME_RELATED_P (i2->rtl ()))) + { + if (dump_file) + fprintf (dump_file, + "rejecting pair (%d,%d): frame-related insn with writeback\n", + i1->uid (), i2->uid ()); + return false; + } + rtx *ignore = &XEXP (pats[1], load_p); for (auto use : insns[1]->uses ()) if (!use->is_mem () diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index a5a6b52730d..32c7317f360 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,48 @@ 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); + } +}