On Mon, 14 Feb 2022 at 10:57, Jan Hubicka <[email protected]> wrote:
> > Hi, > > > > I would like to use ipa_ref in the PASS_LIST all_late_ipa_passes to query > > the statement (ref->stmt) of where a global variable is used. However, I > am > > having some problems achieving this. > > > > What I do is: > > > > 1. Check that ipa_ref->referring has a body and is not inlined. > > 2. get_body > > 3. try to print out the gimple statement using print_gimple_stmt > > (dump_file, ref->stmt, 0, TDF_NONE). > > > > This all seems correct to me, but I have been receiving errors that print > > is trying to print a tree with an incorrect TREE_CODE. I am assuming here > > that ref->stmt is not updated after all_regular_ipa_passes, much like how > > when looking at cgraph_edge the call statement is also not updated. Can > > someone please tell me if this is indeed the case or what is happening > here? > > Yes, while body materialization we keep cgraph edges up to date but we > do not keep references. We probably should remove them earlier. > Keeping them up to date would need relatively some work. We do so for > calls since they hold important information (i.e. where to redirect the > call). For references we don't have such machinery in place (even though > I was thinking implementing it). Main difficulty is that inlining also > performs statement folding that moves referneces around statements quite > freely.... > Hi Honza, just a bit of clarification here, when you are saying that references are not updated do you mean just ipa_ref->stmt or do you also include other things like ipa_ref->referring, ipa_ref->use? Thanks! > > > > Also, while I think that the gimple statements might not be maintained, I > > see that ipa_ref is still used in the ipa_pta pass during > > all_late_ipa_passes. I see that ipa_ref->referring and ipa_ref->stmt are > > not used. Instead the tree of the referred is obtained in the following > > way: ref->referred->decl. I am assuming that it would be possible to use > > ref->referred->decl and search for this tree everywhere in referring to > > find the uses. Can someone confirm this? > > I will check what ipa-pta uses here. I suppose it works since you still > have all references from the pre-IPA-transform stage, so it is > consistent... > > Honza > > > > Thanks! > > -Erick >
