From patchwork Fri Dec 10 12:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 48780 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9ABC03857C75 for ; Fri, 10 Dec 2021 12:54:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 802A73858D35 for ; Fri, 10 Dec 2021 12:54:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 802A73858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 295561F3A1; Fri, 10 Dec 2021 12:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639140878; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xu2Ev2AArpMkb+Y++crOE1ezpW7VYX1OWe574qhnt+M=; b=Ck0w8rHpKppZyOl/qfgBsI46KGl56ZTz4ojJKGW13aEKgA/oC7G/nUBn8MqI4bgIlFN7/m ljoYT8fPZixBkwgNq6M4xTfDFzJzKPYUJkhoMF2O5KObxf/tPzD3BnehyKBxR3QET0kubn AFeu+AXMSX6GRSKCfANhX/0fa0oFJi0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639140878; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xu2Ev2AArpMkb+Y++crOE1ezpW7VYX1OWe574qhnt+M=; b=X4VeeYDllKj93qodBhvphdeC9oSxkDBlh3735p0qQfheDkL+/kWpw2apraTdQt7R/C/d8l WuqyiaMuUSH+0fAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 14A3313E02; Fri, 10 Dec 2021 12:54:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nfAHBA5Os2H9GgAAMHmgww (envelope-from ); Fri, 10 Dec 2021 12:54:38 +0000 Message-ID: <59ba72e8-4fd5-2d91-e934-7f539a7763c2@suse.cz> Date: Fri, 10 Dec 2021 13:54:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] inline: fix ICE with -fprofile-generate To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Hubicka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Fixes ICE spotted by Honza where we have a better place where to check for no_profile_instrument_function attribute. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin PR ipa/103636 gcc/ChangeLog: * ipa-inline.c (can_inline_edge_p): Move logic checking no_profile_instrument_function logic to ... (can_early_inline_edge_p): ... here. --- gcc/ipa-inline.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 54cd085a84d..a1c312f1774 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -396,22 +396,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, e->inline_failed = CIF_SANITIZE_ATTRIBUTE_MISMATCH; inlinable = false; } - else if (profile_arc_flag - && (lookup_attribute ("no_profile_instrument_function", - DECL_ATTRIBUTES (caller->decl)) == NULL_TREE) - != (lookup_attribute ("no_profile_instrument_function", - DECL_ATTRIBUTES (callee->decl)) == NULL_TREE)) - { - cgraph_node *origin = caller; - while (origin->clone_of) - origin = origin->clone_of; - - if (!DECL_STRUCT_FUNCTION (origin->decl)->always_inline_functions_inlined) - { - e->inline_failed = CIF_UNSPECIFIED; - inlinable = false; - } - } if (!inlinable && report) report_inline_failed_reason (e); @@ -637,6 +621,8 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report, static bool can_early_inline_edge_p (struct cgraph_edge *e) { + cgraph_node *caller = (e->caller->inlined_to + ? e->caller->inlined_to : e->caller); struct cgraph_node *callee = e->callee->ultimate_alias_target (); /* Early inliner might get called at WPA stage when IPA pass adds new function. In this case we cannot really do any of early inlining @@ -660,6 +646,13 @@ can_early_inline_edge_p (struct cgraph_edge *e) " edge not inlinable: not in SSA form\n"); return false; } + else if (profile_arc_flag + && ((lookup_attribute ("no_profile_instrument_function", + DECL_ATTRIBUTES (caller->decl)) == NULL_TREE) + != (lookup_attribute ("no_profile_instrument_function", + DECL_ATTRIBUTES (callee->decl)) == NULL_TREE))) + return false; + if (!can_inline_edge_p (e, true, true) || !can_inline_edge_by_limits_p (e, true, false, true)) return false;