From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1611) id C47903858D28; Wed, 18 Jan 2023 14:44:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C47903858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674053049; bh=If/k30C02KxTWDYxbAHdVs0TRrQBUVfU2mZ2eh5btkE=; h=From:To:Subject:Date:From; b=aTkidE4vO5hJY59UaeSPO5MBKWMpyRNHFV2l/LyYi15BU1AmcdS4WISTv8/Wni5Ly jhBd9DBWlK+KLmSvDsDKKajFUYdfRf/UHYUOQW4NM+AnQH93Lwj3DRmjBVh2cnDWkR tqiYdpQ0d7g7TGPg99bVUxBTwlAV8oCPXaw5KRYk= 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 r13-5243] ipa: Release body more carefully when removing nodes (PR 107944) X-Act-Checkin: gcc X-Git-Author: Martin Jambor X-Git-Refname: refs/heads/master X-Git-Oldrev: d4abe5c456a3023f61c3e053255b7dd72ca0d7ec X-Git-Newrev: db959e250077ae6b4fc08f53fb322719582c5de6 Message-Id: <20230118144409.C47903858D28@sourceware.org> Date: Wed, 18 Jan 2023 14:44:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:db959e250077ae6b4fc08f53fb322719582c5de6 commit r13-5243-gdb959e250077ae6b4fc08f53fb322719582c5de6 Author: Martin Jambor 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 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;