public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Jambor <mjambor@suse.cz>
To: "Martin Liška" <mliska@suse.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] IPA: do not release body if still needed
Date: Fri, 13 Jan 2023 17:49:36 +0100	[thread overview]
Message-ID: <ri6mt6mgz1b.fsf@suse.cz> (raw)
In-Reply-To: <a4208860-1af9-6c47-6109-5c2fe4c9d444@suse.cz>

Hi,

sorry for getting to this so late.

On Thu, Dec 01 2022, Martin Liška wrote:
> Hi.
>
> Noticed during building of libbackend.a with the LTO partial linking.

The testcase is areally nice one, too bad it's probably impossible to
get it small enough to be included in the testcase.  But it also fails
to fail for me on trunk, I could only reproduce the problem on the
gcc-12 branch.

>
> The function release_body is called even if clone_of is a clone
> of a another function and thus it shares tree declaration. We should
> preserve it in that situation.
>

But then PR 100413 could happen just one level higher in the clones
hierarchy, not for clone_of but for clone_of->clone_of, no?

I think we need something like the following (only lightly tested so
far, I'll bootstrap it over the weekend):


diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 4bb9e7ba6af..3734c85db63 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -1895,8 +1895,18 @@ cgraph_node::remove (void)
   else if (clone_of)
     {
       clone_of->clones = next_sibling_clone;
-      if (!clone_of->analyzed && !clone_of->clones && !clones)
-	clone_of->release_body ();
+      if (!clones)
+	{
+	  bool need_body = false;
+	  for (cgraph_node *n = clone_of; n; n = n->clone_of)
+	    if (n->analyzed || n->clones)
+	      {
+		need_body = true;
+		break;
+	      }
+	  if (!need_body)
+	    clone_of->release_body ();
+	}
     }
   if (next_sibling_clone)
     next_sibling_clone->prev_sibling_clone = prev_sibling_clone;

Thanks for catching this.

Martin

  parent reply	other threads:[~2023-01-13 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01  9:59 Martin Liška
2022-12-09  8:28 ` Martin Liška
2022-12-28  9:20   ` Martin Liška
2023-01-13 16:49 ` Martin Jambor [this message]
2023-01-14 21:36 ` Jan Hubicka
2023-01-16 12:31   ` Martin Liška
2023-01-18 14:35     ` Martin Jambor
2023-01-18 15:33       ` Jan Hubicka
2023-01-19 17:41         ` Martin Jambor

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=ri6mt6mgz1b.fsf@suse.cz \
    --to=mjambor@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /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).