From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1611) id 49D12385842B; Wed, 1 Feb 2023 17:58:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49D12385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675274335; bh=lj7toGENdaXDhDx2yJMH3NtoSKQx1W0Q/i8iGSf4m6E=; h=From:To:Subject:Date:From; b=jKdXVdp4XKbAsnONTptULgSOxllw/b0+XQQ/YyujPCha4kZFPNUwCgWPSX652TWvu 3aiJPvtXHruWArJxFXA8Vbqm4e9rfIWK3lEYPn3D3I+C3Y9B/IAALRa0I4ftMrw1N9 PzFgH2gLFRNS4UGacNDhXQ5WlEET9eF/x76BmxNc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Martin Jambor To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9096] ipa: Release body more carefully when removing nodes (PR 107944) X-Act-Checkin: gcc X-Git-Author: Martin Jambor X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: fb2d50f72caf3b84b315bc760368670680999749 X-Git-Newrev: 8495d80f44488b2566afc84b3f5704dd7c999e21 Message-Id: <20230201175855.49D12385842B@sourceware.org> Date: Wed, 1 Feb 2023 17:58:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8495d80f44488b2566afc84b3f5704dd7c999e21 commit r12-9096-g8495d80f44488b2566afc84b3f5704dd7c999e21 Author: Martin Jambor Date: Wed Feb 1 18:58:09 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 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) Diff: --- gcc/cgraph.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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;