From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 875B03852742; Tue, 14 Jun 2022 16:41:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 875B03852742 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DCA431F926; Tue, 14 Jun 2022 16:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655224870; h=from:from:reply-to: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=2V4liyDjIfJfziFcz951te3kkUGh3gyGyalj8ALZLmI=; b=G1xaJzuNvkcNr0ggkNab+5ztbLK19csdZ3fxIAKx/BaTTZhYWzHGJYh5P2gwTTGuwYSzub 7mNX4x/7hturHwZ1NYFTqoV6zbMkbaJdyzVyr454ueboJ/q/ixSJlgIQs86vZfvfHB/6eP 6eKMZ1ntIjGM3uehCfc+BkBGWzyjAJI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655224870; h=from:from:reply-to: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=2V4liyDjIfJfziFcz951te3kkUGh3gyGyalj8ALZLmI=; b=HFC9EQPa4UbpzMkmBsHZPlWy9m1UJ/knYnBcgvynNc3AHYXV4oBIotvpK0okotK+KoWSBo HmYD8es+gJk36JAQ== Received: from suse.cz (unknown [10.100.200.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id B94EB2C141; Tue, 14 Jun 2022 16:41:10 +0000 (UTC) From: Martin Jambor To: Erick Ochoa Cc: gcc@gcc.gnu.org Subject: Re: Question on cgraph_edge::call_stmt during LTO In-Reply-To: References: User-Agent: Notmuch/0.35 (https://notmuchmail.org) Emacs/28.1 (x86_64-suse-linux-gnu) Date: Tue, 14 Jun 2022 18:41:07 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 16:41:17 -0000 Hello Erick, sorry for a late reply, I've been recovering from an injury recently. On Thu, Jun 02 2022, Erick Ochoa wrote: > Hi Martin, > > Thanks for the tips! I have implemented an edge summary which: > > * is allocated at IPA analysis phase > * streamed out in ipcp_write_transformation_summaries > * streamed in in ipcp_read_transformation_summaries > > However, before the implementation of this edge summary we had another > mechanism of propagating the information all the way until it was used in a > SIMPLE_IPA_PASS executed after all LGEN stages were finished (after > all_regular_ipa_passes). After changing the implementation to use edge > summaries, I find that the information is conserved during inlining (the > duplication hook prints out the new edges that gets formed via inlining > with the correct information), however it is not found in the > SIMPLE_IPA_PASS that gets executed after all_regular_ipa_passes. I have discussed your situation with Honza and we could not think of a reason why this is happening to you. Summaries have destructors, so we suggest you put a breakpoint in there and see where your summaries get deallocated. > > What is perhaps more interesting is that if I run with -fno-ipa-pure-const > and no -fno-ipa-modref, I can still see the cgraph_nodes and edges of the > inlined methods, along with the information needed. But not in the ones > that have been inlined. I believe this could be just that when these > options are disabled, cgraph_nodes might not be reclaimed. In a late SIMPLE_IPA_PASS? That is really weird, the inlining transformation code quite clearly removes those. How do you even get at these nodes and edges, by traversing the call graph? If not, you might indeed be looking at stale data structures. > I understand that there are many differences between SIMPLE_IPA_PASSes and > regular IPA_PASSes, but at the moment I am unsure how to narrow down my > search for a fix. Is this something that could be caused by: > > * memory management: (I am not familiar with the memory management in GCC > and it is a bit difficult to understand.) I have removed the bodies of the > my_edge_summary::remove (cgraph_edge*) and my_edge_summary::remove > (cgraph_edge *, my_edge_summary_instance *) so I don't think this might be > it. However, the class my_edge_summary still copies some of the structure > in the other transformation summaries, so there is a macro GTY((for_user)) > in the class declaration and the information is stored in a vec va_gc> *my_info. > * missing implementation details in the duplicate functions: Looking at > ipa_edge_args_sum_t::duplicate, it is a relatively complex function. I also > noticed that it does something else when the dst->caller has been inlined. > Should I also update the cgraph_edge that disappears when dst->caller is > inlined to its caller? > * something else? > You probably do not need that complexity. ipa_edge_args_sum_t::duplicate does kind of reference counting so that it can then estimate what references should look like after cloning and inlining, and speculation and speculation-resolutions make this complex. Unless you need to track something similar or treat speculative edges especially for some reason, you can just copy your data and be done with it. > Any direction is greatly appreciated! Sorry if I did not help much and good luck. Martin > > On Sat, 21 May 2022 at 00:13, Martin Jambor wrote: > >> Hello, >> >> On Fri, May 20 2022, Erick Ochoa via Gcc wrote: >> > Hi, >> > >> > I'm working on a pass that looks into the estimated values during ipa-cp >> > and stores them for a later analyses/pass. I would like to store the real >> > arguments' estimates in a cgraph_edge::call_stmt or somewhere else that >> > makes similar sense. (Note, this is different from the formal parameters' >> > estimates which can be found in the lattice print out of ipa-cp). >> >> the statement is not the right place to store such pass-specific >> information, for reasons you described and more (especially simple >> memory use efficiency). >> >> Instead they should be placed into an "edge summary" (also sometimes >> called "call summary"), a structure similar to ipa_edge_args_sum (in >> ipa-prop.h and ipa-prop.cc). Unlike ipa_edge_args_sum, which is >> allocated at analysis phase, then streamed out and in in case of LTO, >> and used thrown away during the IPA analysis phase, your summary would >> need to be allocated at IPA analysis time, then streamed out in >> ipcp_write_transformation_summaries, streamed in in >> ipcp_read_transformation_summaries so that they can be used in the >> transformation phase. >> >> Usually a simple implementation of the duplication hook of an edge >> summary is enough for the data to survive cloning and inlining and the >> like. >> >> Martin >>