From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 9FA1C3858D1E for ; Sat, 14 Jan 2023 21:36:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FA1C3858D1E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 46E7B280F20; Sat, 14 Jan 2023 22:36:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1673732173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R0KpjbMKcFKGPoiqhwvHehfwkF5kWpdtZYSHVl1NiYU=; b=JLHXkdWWC2AMv9mraa1h/9Ee1AxLO4BLTa8idnkLXm1391z2xSteXTABz9Ef0n3FKv27tZ GhEZjgM9ZYcCJ0SS+UZWMk158YNcfo61HJMmLliPu1FNjIGpS04aAkidg2ycA0IkNgyOaI tZPY6k6zZt3ymIjiC/WKK/kMJrTNAvU= Date: Sat, 14 Jan 2023 22:36:13 +0100 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: gcc-patches@gcc.gnu.org, Martin Jambor Subject: Re: [PATCH] IPA: do not release body if still needed Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Hi. > > Noticed during building of libbackend.a with the LTO partial linking. > > 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. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > PR ipa/107944 > > gcc/ChangeLog: > > * cgraph.cc (cgraph_node::remove): Do not release body > if a node is clone of another node. > --- > gcc/cgraph.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc > index f15cb47c8b8..2e7d77ffd6c 100644 > --- a/gcc/cgraph.cc > +++ b/gcc/cgraph.cc > @@ -1893,7 +1893,7 @@ cgraph_node::remove (void) > else if (clone_of) > { > clone_of->clones = next_sibling_clone; > - if (!clone_of->analyzed && !clone_of->clones && !clones) > + if (!clone_of->analyzed && !clone_of->clones && !clones && !clone_of->clone_of) > clone_of->release_body (); It is interesting that the problem reproduced only after almost 20 years. But I suppose it is because we materialize clones in parituclar order. I think there are two ways to fix it. Either declare release_body to be applicable only to the master clone and avoid calling it here (as you do) or make release_body do nothing when called on a clone. I guess it makes sense to keep your approach but please add sanity check to release_body that clone_of == NULL with a comment. OK with that change. Honza > } > if (next_sibling_clone) > -- > 2.38.1 >