From patchwork Tue Jan 9 15:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Coplan X-Patchwork-Id: 1884507 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=WcqS3D/r; 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=WcqS3D/r; 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 4T8ZmT5JH9z1yPf for ; Wed, 10 Jan 2024 02:36:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 417AB38582A2 for ; Tue, 9 Jan 2024 15:36:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2076.outbound.protection.outlook.com [40.107.21.76]) by sourceware.org (Postfix) with ESMTPS id 04C703858C74 for ; Tue, 9 Jan 2024 15:36:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04C703858C74 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 04C703858C74 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.21.76 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704814588; cv=pass; b=t3vg2gDk9JBej+jrbgxDvKtaThFYGzybKXEgZHjV0YHMIvmStNyUL9ZF1PPxz8OC4bnAsJbGTV28PXjvB7fYva848d0FWwUzlV2Qnwy+udFZDvm632b9C0OKh4Dd8AELsWgJGia5IV/4S24oStwt4iZfZJK0YIY0T2FBKLLCeyI= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1704814588; c=relaxed/simple; bh=NuyuD/8qDQg+/+mrbrJu1MvSVW+UTFTlVD7cfiBkqw0=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=jCMUaf36b/L1NUfaE8vcOEymjtAF2fuk3xnaYkI0YgxYR0sjr8zOWgXE0p09BG90K8Xb4sWw+njwhRU1CjDlsSJpC/XqEw/K6hJKpOyyrw0/4j9n5I5JFWdwK3wkABWd0IcfzWbf2mwdNFWUmc7l2Q6YuY50pzggM/jfPnWaVME= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ixLS8P6vQg8mwCwTiVeW5/bw/Xf916Nq7qqa8jFFVYyp8XKFL2Ua27xVmgFBMTXxHYJJAJt7E03ElkzFXpqi1z8cYsJSgXwOht+d5i8ZZU4ikGQ0gHTPwGbDf18+WSaOuMMDbKaATbPmuq10LAUTCc0T4Go077FudoV5Fypwxyxcb+xtqGGM5dHk2cYd1GckeUklMg5j656x2L3u/aYWHhrIkcMTugKBJn9g6sRjMSqUJHdCdvT8g7qS7PDZktquGvzWQRrvIL8j9imc81KHR71EhHCsYv7yM05zCtONSl/cUOLgK+Y1/gOxCoIrCLpTUGtg3jg4FOdsPoDTLXcIhw== 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=rPZH71XkZLcoIc+exSSBJxfVVes4j6GQrsdu4+I1AYk=; b=jjRH3BOj6/iYCI7X0jUM1HgvIKor3h9emeayZyWgAtc2aHG1fn9NTnIUJmAcmqTGlV4Zg9sVyzNVvkXI7RNqvXIbY1qFERpa78yE8TKot9k8qfw+8Jrn77p4/X5FAO+M1W5QFs+JxP4+99LY2QzOKCgdjDnT4AxrSeDhrDCnGKLr6jfOkhcStWTGIPKSo4LlPcRlPMx7VB1cLmB/I9cJX5kBBol4L0dGt21vr7vNrQlI7BWFmdxyxU1JGcTYv2fV8M4PL+C/wXMjut8Qqlj4KKCg8oz+1RR1bKZfMdCwprBpQi8JlLp6z3LiE1AZOyYp4k9+q60JjthnFEru9TCAUw== 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=rPZH71XkZLcoIc+exSSBJxfVVes4j6GQrsdu4+I1AYk=; b=WcqS3D/r1qxvO/FFDbJF7mFxOHhqU4FJNDLTQtt4OPmZ2dKVaQJBGIlAc/5A/guWJTaqZ2aGMdrUt3/u9PPHvTdoYGdbPynGU+s8gNIuFVx9tb4eYcD8lr9wxez58R0DhieclYRkePuHFpukIE6lqvGXNq+5LUMqrcVvWKvQgqk= Received: from AS4P190CA0041.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:5d1::15) by DU5PR08MB10493.eurprd08.prod.outlook.com (2603:10a6:10:518::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Tue, 9 Jan 2024 15:36:20 +0000 Received: from AM4PEPF00025F99.EURPRD83.prod.outlook.com (2603:10a6:20b:5d1:cafe::14) by AS4P190CA0041.outlook.office365.com (2603:10a6:20b:5d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.21 via Frontend Transport; Tue, 9 Jan 2024 15:36:20 +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 AM4PEPF00025F99.mail.protection.outlook.com (10.167.16.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.4 via Frontend Transport; Tue, 9 Jan 2024 15:36:20 +0000 Received: ("Tessian outbound 9bee66383d2d:v239"); Tue, 09 Jan 2024 15:36:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5278e3b51bb4d1a4 X-CR-MTA-TID: 64aa7808 Received: from 803007fc3b69.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3DD87DE9-4D3B-45CF-B3A3-82EEF2F9B279.1; Tue, 09 Jan 2024 15:36:08 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 803007fc3b69.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 09 Jan 2024 15:36:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kW5SXEMsNPmZUWNZtL6Mui1E57HIsq4MtTnCW1HhgJc/ZJ5Zqp4nFKE1Fkb3+G5OGXrpxqkAubnBTnXzZUEUNU8v1nHW1Q8A7z3OoXtI+9kLGEQVfnaDw87GMXpVShRBMcneD3GHqdUNG4NkCkD91vIySQpwvfAwRhE2WHJFuBFJtE6m8CYkC29lkSKxFShxlLZDxOuF7Nxp1rVRHyHKQokJW64B0iKDMng0CfwOr69gSD9vuee8zryx4PumZ450csiPL2gniPhuPmd0KkllZyRbN1pksDu+BmmfJTixRoYvS2+NnZKiuzcuLxHj1zfH6Cj57bc6Je9q+gKE9ndKXA== 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=rPZH71XkZLcoIc+exSSBJxfVVes4j6GQrsdu4+I1AYk=; b=cs9ZkceoRqLS+gyqoZp+hikdtOUN0w6CLbJMRIM2WUbH5lOJwGjdDjjf2gnfvC9P8D2MRNShKLQC7sE1aYy77HhKr6L8iK4eomR8ByHqAqdLgonO7/DHyGHGRjFeZNdxT6SlUdL1ZGJVEN5Gv8HEnbcPnDtXwdth0MVWyw3vgVydeDFBbLtYLp1E6kGU3A9jojbAlnI8RFFfUSO9AIAnIJP468GEv7XlLyjoadt7W0ca9gUjcItcDAo2BnxoCEXS1R30ug1lS+dmMjHB2fsajNWQCXfvF9WXQuz80+CYV2hpOIa+XkpgjhSSblv03hA87nEk/t/N08TFCAB+axba4Q== 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=rPZH71XkZLcoIc+exSSBJxfVVes4j6GQrsdu4+I1AYk=; b=WcqS3D/r1qxvO/FFDbJF7mFxOHhqU4FJNDLTQtt4OPmZ2dKVaQJBGIlAc/5A/guWJTaqZ2aGMdrUt3/u9PPHvTdoYGdbPynGU+s8gNIuFVx9tb4eYcD8lr9wxez58R0DhieclYRkePuHFpukIE6lqvGXNq+5LUMqrcVvWKvQgqk= 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 DBBPR08MB5979.eurprd08.prod.outlook.com (2603:10a6:10:205::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Tue, 9 Jan 2024 15:36:06 +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.7159.020; Tue, 9 Jan 2024 15:36:06 +0000 Date: Tue, 9 Jan 2024 15:36:02 +0000 From: Alex Coplan To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw , Richard Sandiford , Kyrylo Tkachov Subject: [PATCH] aarch64: Fix dwarf2cfi ICEs due to recent CFI note changes [PR113077] Message-ID: Content-Disposition: inline X-ClientProxiedBy: LNXP265CA0028.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5c::16) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|DBBPR08MB5979:EE_|AM4PEPF00025F99:EE_|DU5PR08MB10493:EE_ X-MS-Office365-Filtering-Correlation-Id: e68a4212-1be8-4f3c-8b4c-08dc1128ba99 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: GLKdmu9RFq5haz/Db58q4md9zM1+azSmIdSePbvexgJs3clpWeSqsrNGibet5NOFJxdlJb0hb47/EbAN1zL2YFGSQnSeVo1RNs8EMqv5qMoqo1kmK9bETVT6Znjuep7TJsqWQG6M5/QKIyp6G0khKqB5E3+DMtokJFUA7Yh3udYJByaUC+F1640Cd7YDGpGy8nSm6Fji0hZ3O6gLIznVExO2A2+sz3cwZO70PHyfpF21iyKdvumtfvqfIW6JqHQo+be65WVlZS24yp8WklocXCWSJcDZCnbm6cbMe+AU9d5GEg4FZYNOrW0jCWzIi+LGVgH/WdRBfVeNcXVpm9P3StYdB0c3V7c7AQjLhjqe1RVW6IeBKJGHRPJrZwQTgGhdnmMIIdAhfWed0m1FhhrLR8yKhL8uZEhLhebuzJVCoKF8L8VUk2naUHh9FWx9mbPMeHnbswsyna/3+E4pHINWBuax878nDQ+nFje+mjcAixZvcBmXhDahgt9VXvqmG54vAatXo0vYcMgVXvGXSogHwQtyHPdkI9Ac7p63KigK7mU7oRmu/4ZXVWinuare4D0B2/JdjkBblQsY5VdIxRY076kjlt0c7LnYWAIqMpCLWNlhZeoGMdxnbdMq0B7CaOCZ 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)(396003)(136003)(346002)(366004)(39860400002)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(83380400001)(21480400003)(6506007)(6512007)(2616005)(26005)(38100700002)(8676002)(5660300002)(44832011)(4326008)(235185007)(8936002)(2906002)(54906003)(6486002)(44144004)(33964004)(6666004)(478600001)(66476007)(66556008)(6916009)(316002)(41300700001)(66946007)(86362001)(36756003)(84970400001)(2700100001)(67856001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB5979 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: AM4PEPF00025F99.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 41d87ae1-81e7-4706-4b8f-08dc1128b21e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mo8/1QHOguY9PsiSYkH0ar25qWCZKh/BFx62lYbtgdLSMyc176sAKx/uRiTbvMgqPOdbi82ty1gU9QgHFIBx2FQJwsBS6Kp9KnXN9pkVJLryAij56RGrXVKnnzGeVJEmHPrg6+LxzrHVmgFyQ4boeXhQ84zRQrlYY4oOS0jFCRNr7XdsaPt5O24+pK6Hrx/tPp142Tg54Cz2Ta1PH3zUsRCfDd2YJTAEVaY3ZPqGidwJQUDM7YxUt3xiJ2E+zOR1bmXtUy1Qz4QIiZrjZ5bq+9V+yHDv8frV5nWrf1FBwZ5Ifyn4Og92GfvoHf6Ap6ijhxf80shIdClVzcY4Ct2jDQOiKe9LauH8nz038mT/zcMWEq+FWMUjIGxO8mLfGk5IClszOxUs6/8VXDRwukS/ScMq3xK3h++jIH7hKQhNRbWYpNPvOpfvfLz36nVUNTMxMOFSBCBBcmKrLm8HT/DOz5RKZw9NxIY7XjYiskjHfoFKs5HVQbuMvdn0psF1rQVXLQxrff7vX5h87WJpxhiVvIaaPLDmmn3PW9/7uaUs6ifPoYbdSI9ki0EozPt0DXZOnubSwN4UTgHBqm9w4R9iH6OQ5TYuMYxlnMLLXfdvm+34sJAElEiEZcRiRNFYuqv/5YvEQmegtrzYv35OadQx+Yf7ooYY222bb3x6RJ2DYpsnSboHtZLZF7pWXJkdF5HIwRHDhtEK6DRbpN0nk6sUg1+w/oAmkcIDFjP1AM8Ox4KoErZz0PPcNVJPjN//dL25 X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:; 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)(376002)(39860400002)(346002)(396003)(230922051799003)(64100799003)(1800799012)(82310400011)(186009)(451199024)(36840700001)(40470700004)(46966006)(336012)(2616005)(44144004)(26005)(6486002)(6512007)(6506007)(33964004)(478600001)(82740400003)(47076005)(36860700001)(83380400001)(21480400003)(41300700001)(2906002)(235185007)(70586007)(54906003)(316002)(6916009)(70206006)(4326008)(44832011)(8936002)(8676002)(5660300002)(36756003)(86362001)(356005)(81166007)(6666004)(40460700003)(84970400001)(40480700001)(2700100001)(67856001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2024 15:36:20.5506 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e68a4212-1be8-4f3c-8b4c-08dc1128ba99 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: AM4PEPF00025F99.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU5PR08MB10493 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 Hi, 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). Bootstrapped/regetested on aarch64-linux-gnu, OK for trunk? Thanks, Alex 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..00bc8b749c8 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,65 @@ 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, BASE_REGNO is the chosen base +// register number for the pair, 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, + int base_regno, 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) + { + // Frame-related saves must either be sp-based or must already have + // a REG_FRAME_RELATED_EXPR note. + if (RTX_FRAME_RELATED_P (i1->rtl ()) && !fr_expr[0]) + { + gcc_assert (base_regno == SP_REGNUM); + fr_expr[0] = copy_rtx (pats[reversed]); + } + if (RTX_FRAME_RELATED_P (i2->rtl ()) && !fr_expr[1]) + { + gcc_assert (base_regno == SP_REGNUM); + fr_expr[1] = copy_rtx (pats[!reversed]); + } + } + + // We just built FR_EXPR in program order, now we want it in + // offset order. + if (reversed) + std::swap (fr_expr[0], fr_expr[1]); + + 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 +1438,8 @@ 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, base_regno, pats); rtx pair_pat; if (writeback_effect) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index a5a6b52730d..7b60e874334 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); + } +}