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