aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.cc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2022-04-29 17:38:15 +0200
committerMartin Jambor <mjambor@suse.cz>2022-04-29 17:38:41 +0200
commit27ee75dbe81bb781214c66a9e6a759c08b7deb60 (patch)
treebe7d8a6d76b1bc5e8ae8a1e910d1e8b77d548b42 /gcc/cgraph.cc
parent210cda732832ec589b02c722b2c73f7fa50b97ce (diff)
downloadgcc-27ee75dbe81bb781214c66a9e6a759c08b7deb60.zip
gcc-27ee75dbe81bb781214c66a9e6a759c08b7deb60.tar.gz
gcc-27ee75dbe81bb781214c66a9e6a759c08b7deb60.tar.bz2
ipa: Release body of clone_of when removing its last clone (PR 100413)
In the PR, the verifier complains that we did not manage to remove the body of a node and it is right. The node is kept for materialization of two clones but after one is materialized, the other one is removed as unneeded (as a part of delete_unreachable_blocks_update_callgraph). The problem is that the node removal does not check for this situation and can leave the clone_of node there with a body attached to it even though there is no use for it any more. This patch does checks for it and handles the situation in a simlar way that cgraph_node::materialize_clone does it, except that it also has to be careful that the removed node itself does not have any clones, which would still need the clone_of's body. Failing to do that results in a bootstrap failure. gcc/ChangeLog: 2022-04-27 Martin Jambor <mjambor@suse.cz> PR ipa/100413 * cgraph.cc (cgraph_node::remove): Release body of the node this is clone_of if appropriate. gcc/testsuite/ChangeLog: 2022-04-27 Martin Jambor <mjambor@suse.cz> PR ipa/100413 * g++.dg/ipa/pr100413.C: New test.
Diffstat (limited to 'gcc/cgraph.cc')
-rw-r--r--gcc/cgraph.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 0159eaa..4bb9e7b 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -1893,7 +1893,11 @@ cgraph_node::remove (void)
if (prev_sibling_clone)
prev_sibling_clone->next_sibling_clone = next_sibling_clone;
else if (clone_of)
- clone_of->clones = next_sibling_clone;
+ {
+ clone_of->clones = next_sibling_clone;
+ if (!clone_of->analyzed && !clone_of->clones && !clones)
+ clone_of->release_body ();
+ }
if (next_sibling_clone)
next_sibling_clone->prev_sibling_clone = prev_sibling_clone;
if (clones)