public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Jambor <jamborm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-5243] ipa: Release body more carefully when removing nodes (PR 107944)
Date: Wed, 18 Jan 2023 14:44:09 +0000 (GMT)	[thread overview]
Message-ID: <20230118144409.C47903858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:db959e250077ae6b4fc08f53fb322719582c5de6

commit r13-5243-gdb959e250077ae6b4fc08f53fb322719582c5de6
Author: Martin Jambor <mjambor@suse.cz>
Date:   Wed Jan 18 15:29:54 2023 +0100

    ipa: Release body more carefully when removing nodes (PR 107944)
    
    The code removing function bodies when the last call graph clone of a
    node is removed is too aggressive when there are nodes up the
    clone_of chain which still need them.  Fixed by expanding the check.
    
    gcc/ChangeLog:
    
    2023-01-18  Martin Jambor  <mjambor@suse.cz>
    
            PR ipa/107944
            * cgraph.cc (cgraph_node::remove): Check whether nodes up the
            lcone_of chain also do not need the body.

Diff:
---
 gcc/cgraph.cc | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 5e60c2b73db..5f72ace9b57 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -1893,8 +1893,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;

                 reply	other threads:[~2023-01-18 14:44 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=20230118144409.C47903858D28@sourceware.org \
    --to=jamborm@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).