From patchwork Sun Oct 27 15:12:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 2002995 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=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=jwuoY1w+; 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 4Xc0Y91ZrGz1xw2 for ; Mon, 28 Oct 2024 02:19:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D33243858C42 for ; Sun, 27 Oct 2024 15:19:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xmbghk7.mail.qq.com (xmbghk7.mail.qq.com [43.163.128.48]) by sourceware.org (Postfix) with UTF8SMTPS id C20103858D26 for ; Sun, 27 Oct 2024 15:18:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C20103858D26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cyyself.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C20103858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=43.163.128.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730042327; cv=none; b=DDBb/7fEFvHF9xFDquYUeQl4dsU9LTUT1RSoKOHlzn26obQL23tTkcANSkjySemmlTgmSF4bvBdFG9sEFuyBohgUzP5Q4T+1S1qJYbzs5FMkszhIWFKf5p7HRiNM7ET3Ew5119wErNltq6V8haEFaSnxKQwc3KmKDWWSeINl2FA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730042327; c=relaxed/simple; bh=vfIt+z5wpOzGPc1G5x+MjeiihsMvDZHSpJajoGeWMVM=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=Eaglw5gfpFdwfxvddXBvw+9EOg1zIUdrkZKFfWSPfXVLOa/kZZuYxpB3+qL61/eoPK7/oa28hy0W6bA+WhhJRcYPNXAh9TNB49AEudAeJY6uRe/ZOQ1LrniEWSjagHr2+A8cZoM3SJ1NgYC2lvp4pmqtgIlC/IHDJYYazOeQUQ0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1730042011; bh=6h+FGIBJ88cFZMmDnq3BwPyesu/H6kuecz9ci+afXa8=; h=From:To:Cc:Subject:Date; b=jwuoY1w+Py4VtKolpN5g2eyfTqPnn4V2/l01lelNkUAupbRGl3ob2r0T9i6HeNNtS 55I7z3agduo6rGuaB+RtOg/1AM8jlhzEAkrrDSQyD6XFWsRBT7obrOnOB078I7Cy4S HzySlQW6UJXkVuIWCliJO3q9+C2gCr5OXC98qKqs= Received: from m1.lan ([218.70.255.199]) by newxmesmtplogicsvrszc25-0.qq.com (NewEsmtp) with SMTP id 35BB749A; Sun, 27 Oct 2024 23:13:27 +0800 X-QQ-mid: xmsmtpt1730042007tzrjjjzgf Message-ID: X-QQ-XMAILINFO: MW5hkHoBpWXywNBFwoq16SgJqZVt8V8RdJj448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L0= From: Yangyu Chen To: gcc-patches@gcc.gnu.org Cc: Andrew Carlotti , Martin Liska , Yangyu Chen Subject: [PATCH] Fix MV clones can not redirect to specific target on some targets Date: Sun, 27 Oct 2024 15:12:53 +0000 X-OQ-MSGID: <20241027151253.483284-1-cyy@cyyself.name> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_PBL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP 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 Following the implementation of commit b8ce8129a5 ("Redirect call within specific target attribute among MV clones (PR ipa/82625)"), we can now optimize calls by invoking a versioned function callee from a caller that shares the same target attribute. However, on targets that define TARGET_HAS_FMV_TARGET_ATTRIBUTE to zero, meaning they use the "target_versions" attribute instead of "target", this optimization is not feasible. Currently, the only target affected by this limitation is AArch64. This commit resolves the issue by not directly using "target" with lookup_attribute. Instead, it checks the TARGET_HAS_FMV_TARGET_ATTRIBUTE macro to decide between using the "target" or "target_version" attribute. Fixes: 79891c4cb5 ("Add support for target_version attribute") gcc/ChangeLog: * multiple_target.cc (redirect_to_specific_clone): Fix the redirection does not work on target without TARGET_HAS_FMV_TARGET_ATTRIBUTE. --- gcc/multiple_target.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/multiple_target.cc b/gcc/multiple_target.cc index d2c9671fc1b..a1c18f4a3a7 100644 --- a/gcc/multiple_target.cc +++ b/gcc/multiple_target.cc @@ -446,8 +446,10 @@ redirect_to_specific_clone (cgraph_node *node) cgraph_function_version_info *fv = node->function_version (); if (fv == NULL) return; + const char *fmv_attr = (TARGET_HAS_FMV_TARGET_ATTRIBUTE + ? "target" : "target_version"); - tree attr_target = lookup_attribute ("target", DECL_ATTRIBUTES (node->decl)); + tree attr_target = lookup_attribute (fmv_attr, DECL_ATTRIBUTES (node->decl)); if (attr_target == NULL_TREE) return; @@ -458,7 +460,7 @@ redirect_to_specific_clone (cgraph_node *node) if (!fv2) continue; - tree attr_target2 = lookup_attribute ("target", + tree attr_target2 = lookup_attribute (fmv_attr, DECL_ATTRIBUTES (e->callee->decl)); /* Function is not calling proper target clone. */ @@ -472,7 +474,7 @@ redirect_to_specific_clone (cgraph_node *node) for (; fv2 != NULL; fv2 = fv2->next) { cgraph_node *callee = fv2->this_node; - attr_target2 = lookup_attribute ("target", + attr_target2 = lookup_attribute (fmv_attr, DECL_ATTRIBUTES (callee->decl)); if (attr_target2 != NULL_TREE && attribute_value_equal (attr_target, attr_target2))