This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Update string_constant for new const initializer code


On Sun, 5 Sep 2010, Jan Hubicka wrote:

> > On Sat, 4 Sep 2010, Jan Hubicka wrote:
> > 
> > > Hi,
> > > while disabling initializer folding in expr.c I noticed that string-constant is
> > > actually used by builtin folding and thus it needs to be updated for new
> > > varppol initializer code.  Unfortunately folding also happens early from
> > > frntend and thus we need to  behave sanely when varpool is not ready yet.  The
> > > patch removes TREE_SIDE_EFFECTS check since we don't do it elsewhere
> > > (and I have problems to think of volatile constant string having some meaning)
> > > and also makes us to use DECL_REPLACEABLE_P instead of targetm.binds_local_p
> > > like we do elsewhere now too.
> > > 
> > > Bootstrapped/regtested x86_64-linx, OK?
> > > 
> > > Honza
> > > 
> > > 	* expr.c (string_constant): Use varpool to figure out if value
> > > 	is known.
> > > Index: expr.c
> > > ===================================================================
> > > --- expr.c	(revision 163859)
> > > +++ expr.c	(working copy)
> > > @@ -9815,10 +9837,12 @@ string_constant (tree arg, tree *ptr_off
> > >  	  || TREE_CODE (DECL_INITIAL (array)) != STRING_CST)
> > >  	return 0;
> > >  
> > > -      /* If they are read-only, non-volatile and bind locally.  */
> > > +      /* If they are read-only and non-replaceable.  */
> > >        if (! TREE_READONLY (array)
> > > -	  || TREE_SIDE_EFFECTS (array)
> > > -	  || ! targetm.binds_local_p (array))
> > > +	  || ((!cgraph_function_flags_ready
> > > +	       && !DECL_REPLACEABLE_P (array))
> > > +	      || (cgraph_function_flags_ready
> > > +		  && !varpool_get_node (array)->const_value_known)))
> > 
> > So DECL_REPLACEABLE_P isn't kept up-to-date?  Why does
> > 
> >   || !DECL_REPLACEABLE_P (array)
> > 
> > not work?
> 
> Well, because of the WHOPR partitioning where we can turn
> static const int a;
> into
> extern const int a;
> that is replaceable yet we know that initializer is 0.

So if it is replaceable then why is the check necessary?  The function
looks at DECL_INITIAL anyway and I hope that is not set when
!varpool_get_node (array)->const_value_known but DECL_REPLACEABLE_P is
true?

I'd hate to have two mechanisms that can easily get out of sync.

But maybe I'm missing sth.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]