> 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....
> 
> 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

Reply via email to