]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa: Release body more carefully when removing nodes (PR 107944)
authorMartin Jambor <mjambor@suse.cz>
Wed, 1 Feb 2023 17:58:09 +0000 (18:58 +0100)
committerMartin Jambor <mjambor@suse.cz>
Wed, 1 Feb 2023 17:58:26 +0000 (18:58 +0100)
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.

(cherry picked from commit db959e250077ae6b4fc08f53fb322719582c5de6)

gcc/cgraph.cc

index 4bb9e7ba6af98a85c857d97ff7888fa0f2df81d6..3734c85db637883e116834de3ec4f517a2ba5379 100644 (file)
@@ -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;