From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 1786B3858D28 for ; Wed, 18 Jan 2023 14:35:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1786B3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E6A9A5BF21; Wed, 18 Jan 2023 14:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1674052535; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jv8no/IlPpq8v23gG+4kMkudvqlPuZQZSEfhWLr8VS4=; b=e8OlNJNor52ppCnMDSRdBMVCsn4buHyzEoO28k6LjZox4xT9c6zupRyDvcsYRzl/gkyN2h yuDyFJBJRZLk4f/6G0Ima7I59Ba4OrcFOXg12xKPpCetr8SGFO6/3TXnSGvFnpYn4VrTZx s4jILtCsIo2cnVpEJZA5auY1CyPmtj4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1674052535; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jv8no/IlPpq8v23gG+4kMkudvqlPuZQZSEfhWLr8VS4=; b=ryI0fxxQbSMmlEreiFFWlaIVuVIys0NRgmOX/tP0SfI/UcvnfY1bBULhNqsHXxdBzJyref Gps9F4ePTFxh4tAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D9C29138FE; Wed, 18 Jan 2023 14:35:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9mMgNbcDyGNhZwAAMHmgww (envelope-from ); Wed, 18 Jan 2023 14:35:35 +0000 From: Martin Jambor To: Martin =?utf-8?Q?Li=C5=A1ka?= , Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] IPA: do not release body if still needed In-Reply-To: <9070c8aa-3496-7424-6c4b-33d1e5606b31@suse.cz> References: <9070c8aa-3496-7424-6c4b-33d1e5606b31@suse.cz> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Wed, 18 Jan 2023 15:35:35 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_SOFTFAIL,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, On Mon, Jan 16 2023, Martin Li=C5=A1ka wrote: > On 1/14/23 22:36, Jan Hubicka wrote: >>> 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 =3D next_sibling_clone; >>> - if (!clone_of->analyzed && !clone_of->clones && !clones) >>> + if (!clone_of->analyzed && !clone_of->clones && !clones && !clon= e_of->clone_of) >>> clone_of->release_body (); >>=20 >> It is interesting that the problem reproduced only after almost 20 >> years. But I suppose it is because we materialize clones in parituclar >> order. > > Well, it started with r13-48-g27ee75dbe81bb7 where Martin add a new code > that calls the release_body function. So it's pretty new. > >>=20 >> 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 =3D=3D NULL with a comment. > > I do support Martin's enhanced version of the patch. > I take that as an approval, so I am about to commit the following after re-testing it on trunk. Afterwards I'll backport it to the affected release branches too. Thanks, Martin 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. --- 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 =3D next_sibling_clone; - if (!clone_of->analyzed && !clone_of->clones && !clones) - clone_of->release_body (); + if (!clones) + { + bool need_body =3D false; + for (cgraph_node *n =3D clone_of; n; n =3D n->clone_of) + if (n->analyzed || n->clones) + { + need_body =3D true; + break; + } + if (!need_body) + clone_of->release_body (); + } } if (next_sibling_clone) next_sibling_clone->prev_sibling_clone =3D prev_sibling_clone; --=20 2.39.0