From patchwork Wed Oct 18 15:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Carlotti X-Patchwork-Id: 154938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4884799vqb; Wed, 18 Oct 2023 08:45:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFB6erbumTSmB87cQmxRxulaoeTa+HPZCvfEYkUaFm0rrykj2zpsBZaItBRdzIR0ZrrMtgI X-Received: by 2002:a05:6214:248e:b0:66d:5cfe:82a6 with SMTP id gi14-20020a056214248e00b0066d5cfe82a6mr10112820qvb.27.1697643934515; Wed, 18 Oct 2023 08:45:34 -0700 (PDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qr2-20020a05620a390200b00777722d8abfsi104072qkn.244.2023.10.18.08.45.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="MY3JIK+/"; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b="MY3JIK+/"; arc=fail (previous hop failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49ADC3858028 for ; Wed, 18 Oct 2023 15:45:34 +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-he1eur04on2041.outbound.protection.outlook.com [40.107.7.41]) by sourceware.org (Postfix) with ESMTPS id 4DBB3385700B for ; Wed, 18 Oct 2023 15:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DBB3385700B 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 4DBB3385700B Authentication-Results: server2.sourceware.org; arc=fail smtp.remote-ip=40.107.7.41 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697643910; cv=fail; b=UvQWkCgF39Ssg2NBhjfh2zTIUf5qFDxyd3L8kvRR6JHksuVrTkDCASbgC4pdd63gwb0Vl5uarqBgRctZVCR1M69YngZACv+4qQdMspz2CfZGxMYZ4b0bOwrQqe/KtFQ+45eBi8Y4AcEWyYkV/9vDnBvF/NQKm+Ww44G3wpebDCs= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1697643910; c=relaxed/simple; bh=nvCx2IRxATf5Pizj0kIfHjqpQdeeHph8EyagqkHqJiw=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=klruKMl2M/Fd21toP+7y9HiJgrb6CHWSPCqDTGV22j6ctSbC8bltaBXXbj1+C4+RFPvKs1qhplIqHw21EI3KALfkQpeRiZO/lDobfwkHMW70nyiQ1HbY3ImrXrtW0VtXhA7c5PHU9a6FHzN9+nZLqV3jEeGWrz2GOJ4ab7CjP4k= ARC-Authentication-Results: i=2; server2.sourceware.org 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=O4bg6xqwEwKFS9na7gvCdrlJ5gGGHLvrQFtaT1Sw9gg=; b=MY3JIK+/GD9ck2e6bGz46ELGhDSw+N8iu5lRQgRtP/PD+AzGkHNJYBc8m/OLmyUWNMC4AQRuEe2Izb46XL8tvQev0kmw43qI1sYSl5O16WhyrsMscIRusiiJ9mDUaJLG0kZ/wdxyerPOjhAvtVAoAuWdcdhmQrq5Xpl9YsqitUs= Received: from AM0PR02CA0187.eurprd02.prod.outlook.com (2603:10a6:20b:28e::24) by DU0PR08MB9902.eurprd08.prod.outlook.com (2603:10a6:10:476::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 15:45:04 +0000 Received: from AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:28e:cafe::7) by AM0PR02CA0187.outlook.office365.com (2603:10a6:20b:28e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36 via Frontend Transport; Wed, 18 Oct 2023 15:45:04 +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 AM7EUR03FT043.mail.protection.outlook.com (100.127.140.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24 via Frontend Transport; Wed, 18 Oct 2023 15:45:04 +0000 Received: ("Tessian outbound 028b72acc2da:v215"); Wed, 18 Oct 2023 15:45:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c42813379dbd4448 X-CR-MTA-TID: 64aa7808 Received: from f3b770d2b5fa.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C48A3D16-4555-4B3F-9F03-DCCEA5889E08.1; Wed, 18 Oct 2023 15:44:57 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f3b770d2b5fa.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 18 Oct 2023 15:44:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h8LVp1dzYBt52XwSjQMjwjBvP/ZF0AzOwR3zNTeRKZP4MRotsGK4TYQiPD+rWS80b5qHfNmCnkyu5HgOZ8JaPyH/uO7/KCAt6ZLJ2qYNxgyMlEW0s1TdjUlMcIW5UapMJz/Q5zELyrW03gfWtsplw0KH29M+7aj+ojizR/ZvySS/pSbY1GwZ8FRvzGZQlKyoJ9SfCE4QFblXouDL0WR+QuYcwEmkQjnLoyyH9FV5AjQOYUlsIt4CqPAJVjSCHW3yO5DMjeR8wTz3HaVVmpoFWbI4v3zHmHVabqUXhomPHLT2GcCAFkS/R5O6HsTRCYI+5Tqp5rVVmFZoXBDOYtSt3A== 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=O4bg6xqwEwKFS9na7gvCdrlJ5gGGHLvrQFtaT1Sw9gg=; b=Wxia46M7jA9JOUGzibw9H12vCawdo5ibaMux5Xri7CHAvXtfB0GR5Uh87W00xqETrVF9QJ3E2N+iR6wU0qz8lloZCbhL3rLCOC1BUi6Nj1zU4nA7/2DJAJUmc/I4mIEEjyFEbtWhh7r3hXChJ3jqijPfetHCEWZ00gJyK+FGurLme07IFbYqPovf5Dz8KPYKpbDhCU8mskhzjn1O6WpHTzCn0FEQrygYcRUc+LQUv2FFEJbAqKUMakMTxJqqpE7gTgWLGfjgfxz0f9yYhWmsnT1WDZaZdHG1YBdAZVQOx8Nm+s0QzDJrdTEWHLP0sfXKCeVfbKdRJfOp/GiYqfP2Mw== 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=O4bg6xqwEwKFS9na7gvCdrlJ5gGGHLvrQFtaT1Sw9gg=; b=MY3JIK+/GD9ck2e6bGz46ELGhDSw+N8iu5lRQgRtP/PD+AzGkHNJYBc8m/OLmyUWNMC4AQRuEe2Izb46XL8tvQev0kmw43qI1sYSl5O16WhyrsMscIRusiiJ9mDUaJLG0kZ/wdxyerPOjhAvtVAoAuWdcdhmQrq5Xpl9YsqitUs= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) by AS8PR08MB9120.eurprd08.prod.outlook.com (2603:10a6:20b:5c1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 15:44:56 +0000 Received: from AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::3880:6a2c:60e:3f3e]) by AS8PR08MB6678.eurprd08.prod.outlook.com ([fe80::3880:6a2c:60e:3f3e%7]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 15:44:56 +0000 Date: Wed, 18 Oct 2023 16:44:55 +0100 From: Andrew Carlotti To: gcc-patches@gcc.gnu.org Subject: [3/3] WIP/RFC: Fix name mangling for target_clones Message-ID: <36b6307f-10f5-c03e-0263-0671d3219eb9@e124511.cambridge.arm.com> References: <26bbc7e4-9d5a-fef3-2f78-1b7a03865050@e124511.cambridge.arm.com> Content-Disposition: inline In-Reply-To: <26bbc7e4-9d5a-fef3-2f78-1b7a03865050@e124511.cambridge.arm.com> X-ClientProxiedBy: LO2P265CA0262.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::34) To AS8PR08MB6678.eurprd08.prod.outlook.com (2603:10a6:20b:398::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6678:EE_|AS8PR08MB9120:EE_|AM7EUR03FT043:EE_|DU0PR08MB9902:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bd06bed-960b-4076-2979-08dbcff132ae 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: qcz8PerVgm5ij/U1/fwamruy/GAII0h73QkH8ALCKGdlLblYG12PH9k/U4U3F67sYZO2cEdgukKuWBwIhLDiwrM2rva0y9Td2z/oVhINmQNsZJP1F1it2tl23L6U5jLS9hscNWuc4X4BcNmxqwtHYEdFTeSxQG3MtScUtcDHmBZI0mLVlEVsmlCyvAyBYd7cl/x5/NSmpU2bmJz0aq+pTmQrcc84XpY9PZ0XsyNq77O1h3u1xVp8pyNk7pw6gTk1v002Hrnst6gGHcyoKeBe2aBLuJsihzHo/7Trzw7HJSY8Se0RxqGwpU+ufbm4JGEkYrXLYbM5ZqcSXC5NALB/AROQI5DD282n2EVwK/oWhc5oj3zwsPU1x0brQDhQ4vlULU+xmm33lIyMf/0ZIhuGsWEqH2Kh7wmpnJbe99QzexwruWL8d1FL6bBu8jwG8K3ogOBNQa6fq3mPa8GdCgWEoCRfQBHdsHb+Wh0O1OEMhmMU1Fclu4FxyaeGMRAMayuPMkJTy87PYS3sL2md+b4TXVaYb/Uikb2/r3htNHbIfv22fO9pVoGVjutSzO0thp9u X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6678.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(39860400002)(366004)(136003)(346002)(376002)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(26005)(6506007)(8936002)(66946007)(5660300002)(44832011)(41300700001)(8676002)(478600001)(2906002)(6486002)(316002)(6916009)(66556008)(66476007)(86362001)(31696002)(38100700002)(31686004)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9120 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: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5b5f76b8-2119-4905-5817-08dbcff12d64 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: up+vVDa8D0LmmnGmW7frCi/UbP24PN4Q8AFE4KnfXjWrDmFOcDDncW5hekKzXM9QS0kfpKPBgGHVH82pKEtK9Jg9k38AUuq8EpNgkdW8vkKMhnPVjBEErjzzyumxh/O7en6W4L/HiEpYBgTw9VAp3+HwOCcGeS9/xj3bMCjG2s0sajQLxAmjd65XBFlQVzzY8+hSUi9O7b37Kzkhxiou/Oo5uPDlx5KuMioqRpB9l3plxh1+RczBUn45mnza8wWgeGUt0G8AC95PRz3q/gi1W5+seGHZEIv1VX33OKM5CfnoArFNwyeT4/47hznBG1l/b1k+Dgn4QFeSE7G7WFZ2Dougo3TKPvxiB9K3KZTOGTSZ92qKtozSzPVrpkdyGRIvNwZs3T09kwlaAB0ls6Kpxzk5IJUFkgCFV8BgKoS40WoQTykJ4Tb6IiEg0XC4hto8IdoDSFIxSHsum2EtH/Seg3Qdt3ikxoET2/+kQK6mylVwsX6cCbdHg9Tp5EjVvRMCIqirdiVqq9li1mVdroDn819OCY7eLiaiY15AV4gWCrYDqff149AQXWvqZrUBE03KUnOud98RXMQUKI4VcOl6NmG14S+lMI21eCxI/OOmvGVAXb7bwmPW6XZqJChQhpSY/tfwMKHndR0VDaRY/KfyTAcuOOEOb9l9ZjPLN0+BBIri9NLaw7/j5S8nRvhar4MSF7oJnvWI4mLgRczgOr9n/jsWsmlvi2uBU0jmKS+h3qb/JJpE+AIQmZQwIHpHMM7v 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)(396003)(39860400002)(376002)(136003)(346002)(230922051799003)(1800799009)(186009)(64100799003)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(6486002)(478600001)(6506007)(6512007)(44832011)(336012)(2906002)(8676002)(8936002)(5660300002)(70206006)(70586007)(6916009)(41300700001)(316002)(47076005)(36860700001)(31696002)(86362001)(81166007)(82740400003)(356005)(26005)(40460700003)(40480700001)(31686004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 15:45:04.6774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9bd06bed-960b-4076-2979-08dbcff132ae 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: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9902 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780108685989035737 X-GMAIL-MSGID: 1780108685989035737 This is a partial patch to make the mangling of function version names for target_clones match those generated using the target or target_version attributes. It modifies the name of function versions, but does not yet rename the resolved symbol, resulting in a duplicate symbol name (and an error at assembly time). Is this sort of approach ok? Should I create an extra target hook to be called here, so that the target_clones mangling can be target-specific but not necessarily the same as for target attribute versioning? diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc index 8af6b23d8c0306920e0fdcb3559ef047a16689f4..15672c02c6f9d6043a36bf081067f08d1ab834e5 100644 --- a/gcc/cgraphclones.cc +++ b/gcc/cgraphclones.cc @@ -1033,11 +1033,6 @@ cgraph_node::create_version_clone_with_body else new_decl = copy_node (old_decl); - /* Generate a new name for the new version. */ - tree fnname = (version_decl ? clone_function_name_numbered (old_decl, suffix) - : clone_function_name (old_decl, suffix)); - DECL_NAME (new_decl) = fnname; - SET_DECL_ASSEMBLER_NAME (new_decl, fnname); SET_DECL_RTL (new_decl, NULL); DECL_VIRTUAL_P (new_decl) = 0; @@ -1065,6 +1060,24 @@ cgraph_node::create_version_clone_with_body return NULL; } + /* Generate a new name for the new version. */ + if (version_decl) + { + tree fnname = (clone_function_name_numbered (old_decl, suffix)); + DECL_NAME (new_decl) = fnname; + SET_DECL_ASSEMBLER_NAME (new_decl, fnname); + } + else + { + /* Add target version mangling. We assume that the target hook will + produce the same mangled name as it would have produced if the decl + had already been versioned when the hook was previously called. */ + tree fnname = DECL_ASSEMBLER_NAME (old_decl); + DECL_NAME (new_decl) = fnname; + fnname = targetm.mangle_decl_assembler_name (new_decl, fnname); + SET_DECL_ASSEMBLER_NAME (new_decl, fnname); + } + /* When the old decl was a con-/destructor make sure the clone isn't. */ DECL_STATIC_CONSTRUCTOR (new_decl) = 0; DECL_STATIC_DESTRUCTOR (new_decl) = 0; diff --git a/gcc/multiple_target.cc b/gcc/multiple_target.cc index 3db57c2b13d612a37240d9dcf58ad21b2286633c..d9aec9a5ab532701b4a1877b440f3a553ffa28e2 100644 --- a/gcc/multiple_target.cc +++ b/gcc/multiple_target.cc @@ -162,7 +162,12 @@ create_dispatcher_calls (struct cgraph_node *node) } } - tree fname = clone_function_name (node->decl, "default"); + /* Add version mangling to default decl name. We assume that the target + hook will produce the same mangled name as it would have produced if the + decl had already been versioned when the hook was previously called. */ + tree fname = DECL_ASSEMBLER_NAME (node->decl); + DECL_NAME (node->decl) = fname; + fname = targetm.mangle_decl_assembler_name (node->decl, fname); symtab->change_decl_assembler_name (node->decl, fname); if (node->definition)