On Wed, 2 Sep 2015, Jan Hubicka wrote: > > > > I was naiively using ->get_constructor in IPA PTA without proper > > checking on wheter that succeeds. Now I tried to use ctor_for_folding > > but that isn't good as we want to analyze non-const globals in IPA > > PTA and we need to analyze their initialiers as well. > > > > Thus I'm trying below with ctor_for_analysis, but I really "just" > > need the initializer or a "not available" for conservative handling. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > Honza - I suppose you should doble-check this and suggest sth > > different (or implement sth more generic in the IPA infrastructure). > > Yep, you are correct that we don't currently have way to look into ctor > without actually loading. But do you need something more than just walking > references that you already have in ipa-ref lists?
Hmm, no, ipa-ref list should be enough (unless we start field-sensitive analysis or need NULL inits for correctness). Still have to figure out how to walk the list and how the reference would look like (what is ref->use? IPA_REF_ADDR? can those be speculative?) Richard. > > > > Thanks, > > Richard. > > > > 2015-09-02 Richard Biener <rguent...@suse.de> > > > > PR ipa/66705 > > * tree-ssa-structalias.c (ctor_for_analysis): New function. > > (create_variable_info_for_1): Use ctor_for_analysis instead > > of get_constructor. > > (create_variable_info_for): Likewise. > > Otherwise I would go for making ctor_for_analysis a method of varpool_node > and... > > > > * g++.dg/lto/pr66705_0.C: New testcase. > > > > Index: gcc/tree-ssa-structalias.c > > =================================================================== > > --- gcc/tree-ssa-structalias.c (revision 227207) > > +++ gcc/tree-ssa-structalias.c (working copy) > > @@ -5637,6 +5637,26 @@ check_for_overlaps (vec<fieldoff_s> fiel > > return false; > > } > > > > +/* We can't use ctor_for_folding as that only returns constant > > constructors. */ > > + > > +static tree > > +ctor_for_analysis (tree decl) > > +{ > > + varpool_node *node = varpool_node::get (decl); > > + if (!node) > > + return error_mark_node; > > + node = node->ultimate_alias_target (); > > + if (DECL_INITIAL (node->decl) != error_mark_node > > + || !in_lto_p) > > + return (DECL_INITIAL (node->decl) > > + ? DECL_INITIAL (node->decl) : error_mark_node); > > I think returning NULL here is just fine. > error_mark_node means constructor is not really available. NULL is > the usual way to say that the variable is not initialized. > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)