Update string_constant for new const initializer code
Richard Guenther
rguenther@suse.de
Sun Sep 5 08:49:00 GMT 2010
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?
Richard.
More information about the Gcc-patches
mailing list