public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5931] inline: fix ICE with -fprofile-generate
Date: Mon, 13 Dec 2021 13:58:45 +0000 (GMT)	[thread overview]
Message-ID: <20211213135845.EB019385781B@sourceware.org> (raw)

https://gcc.gnu.org/g:9eb8785b3fa3a180bd216cf68b53f1621628efc6

commit r12-5931-g9eb8785b3fa3a180bd216cf68b53f1621628efc6
Author: Martin Liska <mliska@suse.cz>
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;


                 reply	other threads:[~2021-12-13 13:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211213135845.EB019385781B@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).