From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1611) id DF0013858C60; Thu, 2 Feb 2023 11:28:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF0013858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675337335; bh=oo4HHMjO8yYKaO7gNHxyAYGEE99v8Ecp4I9K3Y5hLC4=; h=From:To:Subject:Date:From; b=uZgrvItcrGc6qVvW7toJVKmvgbriK6a0Ux54rWKG2kodvoo0iaLNOf80/ODhSQH9k G7X2hpQWMGf2c9vNb54DMtepFHqpuvpIwFao/fwQo5kpV1ojogNOg9l9o7tnkTPOb5 kBS6jEHmaz56vvHQFTOuxLp8hZSgCuTemxMNUiFo= 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 r11-10496] 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-11 X-Git-Oldrev: 29c7f19051ee7d3bf1f82eb91c013fd19bd47534 X-Git-Newrev: e36385be53d51539e1c295a80085115b24fede32 Message-Id: <20230202112855.DF0013858C60@sourceware.org> Date: Thu, 2 Feb 2023 11:28:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e36385be53d51539e1c295a80085115b24fede32 commit r11-10496-ge36385be53d51539e1c295a80085115b24fede32 Author: Martin Jambor Date: Thu Feb 2 12:22:22 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.c (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.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 4e3e348513b..6e523e14e05 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1908,8 +1908,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;