From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 603AB385802B; Fri, 10 Dec 2021 10:41:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 603AB385802B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/PR103636-fix-inlining-with-pgo)] inline: fix ICE with -fprofile-generate X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/PR103636-fix-inlining-with-pgo X-Git-Oldrev: db184a3453b6fe810e2d9765ef8ed9028f96e968 X-Git-Newrev: a8bb6d19c1193c69d331cf128b7b995e0300f802 Message-Id: <20211210104147.603AB385802B@sourceware.org> Date: Fri, 10 Dec 2021 10:41:47 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Dec 2021 10:41:47 -0000 https://gcc.gnu.org/g:a8bb6d19c1193c69d331cf128b7b995e0300f802 commit a8bb6d19c1193c69d331cf128b7b995e0300f802 Author: Martin Liska Date: Fri Dec 10 11:40:54 2021 +0100 inline: fix ICE with -fprofile-generate 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. Diff: --- 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;