From patchwork Mon Oct 21 18:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 2000068 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=ju5n9fTB; 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 4XXPTj4j5Nz1xvv for ; Tue, 22 Oct 2024 05:48:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 945653858423 for ; Mon, 21 Oct 2024 18:48:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out203-205-221-245.mail.qq.com (out203-205-221-245.mail.qq.com [203.205.221.245]) by sourceware.org (Postfix) with UTF8SMTPS id 883A6385842C for ; Mon, 21 Oct 2024 18:47:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 883A6385842C 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 883A6385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=203.205.221.245 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729536458; cv=none; b=Zmt7VbvGkdEGa8L5YBCDlmK0C9ccVaFLbuojqdOQtmazod0suuXHri7AS/a0SoOi2nO6jXeB0h1IEYIQA4z+dA+DrB/aDqFinvlMMDiQsSbYKw6pCbXm8nYMU+dpof3jm8XF6PWbVRqZv+Igud4K2xJD2Gev2tfPVOWPWJ0b2NA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729536458; c=relaxed/simple; bh=zJJBr1+BualNjnuokGtuv2/uFHiwC8ToxDsdeMLqYPg=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=uWCddrXfcoY565fy+XR6w4OWvuTUe5GxXQIJ7TmFiL+wgePQPi32sR4UK/bqbfAnUasRDDGXv+1JSiJMb4Gh+Y9ufMDF/Od2vIq6JGV1pWShERvpUcS8LUBPwlsNSRoLfUPWH20HnF4FwNHbNFcoq84dpR/sm6Fw0EbJJwX2IE8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1729536443; bh=74VKz13Ljn4TaqLwiDPUXhDX4xASOK1NbeWOl8jiw0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ju5n9fTBcGKSls4aDVqrAwXnd6VVNtdc2dIh9aNaJtytf8H9qEgwCpwAgKDyhkFZC cCuDrliguhAPR78r+tdxs3fZ1uFKs9NnGcoCarO5N23bNGZqz9xlcVHuVuO5ej6BG9 wRJj2sDCtK3CHQ3BdfsfkraoOgaXUjz0il2lBrkA= Received: from cyy-pc.lan ([240e:379:227f:d300:3578:1918:1859:abc5]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id BD537038; Tue, 22 Oct 2024 02:47:21 +0800 X-QQ-mid: xmsmtpt1729536441tzbkamijq Message-ID: X-QQ-XMAILIN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5hPFx9JQPQ5GfPF2zv8K9vxpddqJ4k X-QQ-XMRINFO: OWPUhxQsoeAVDbp3OJHYyFg= From: Yangyu Chen To: gcc-patches@gcc.gnu.org Cc: Kito Cheng , Palmer Dabbelt , Jiawei , Jeff Law , Evgeny Stupachenko , Andrew Carlotti , Yangyu Chen Subject: [PATCH v2 08/11] RISC-V: Do not inline when callee is versioned but caller is not Date: Tue, 22 Oct 2024 02:47:20 +0800 X-OQ-MSGID: <20241021184720.3259750-1-cyy@cyyself.name> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HELO_DYNAMIC_IPADDR, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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 When the callee is versioned but the caller is not, we should not inline the callee into the caller, to prevent the default version of the callee from being inlined into a not versioned caller. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_can_inline_p): Refuse to inline when callee is versioned but caller is not. --- gcc/config/riscv/riscv.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index f7082df22ef..46961360096 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -7666,6 +7666,10 @@ riscv_compute_frame_info (void) static bool riscv_can_inline_p (tree caller, tree callee) { + /* Do not inline when callee is versioned but caller is not. */ + if (DECL_FUNCTION_VERSIONED (callee) && ! DECL_FUNCTION_VERSIONED (caller)) + return false; + tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee); tree caller_tree = DECL_FUNCTION_SPECIFIC_TARGET (caller);