Commit ba30e50d by Tom de Vries Committed by Tom de Vries

emit-rtl.c (set_mem_attributes_minus_bitpos): Set MEM_READONLY_P for static const strings.

2011-10-13  Tom de Vries  <tom@codesourcery.com>

	* emit-rtl.c (set_mem_attributes_minus_bitpos): Set MEM_READONLY_P
	for static const strings.
	* varasm.c (build_constant_desc): Generate the memory location of the
	constant using gen_const_mem.

From-SVN: r179896
parent 6c9fbfa7
2011-10-13 Tom de Vries <tom@codesourcery.com>
* emit-rtl.c (set_mem_attributes_minus_bitpos): Set MEM_READONLY_P
for static const strings.
* varasm.c (build_constant_desc): Generate the memory location of the
constant using gen_const_mem.
2011-10-13 Richard Guenther <rguenther@suse.de> 2011-10-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50698 PR tree-optimization/50698
...@@ -1696,6 +1696,12 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, ...@@ -1696,6 +1696,12 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
&& !TREE_THIS_VOLATILE (base)) && !TREE_THIS_VOLATILE (base))
MEM_READONLY_P (ref) = 1; MEM_READONLY_P (ref) = 1;
/* Mark static const strings readonly as well. */
if (base && TREE_CODE (base) == STRING_CST
&& TREE_READONLY (base)
&& TREE_STATIC (base))
MEM_READONLY_P (ref) = 1;
/* If this expression uses it's parent's alias set, mark it such /* If this expression uses it's parent's alias set, mark it such
that we won't change it. */ that we won't change it. */
if (component_uses_parent_alias_set (t)) if (component_uses_parent_alias_set (t))
......
...@@ -3119,7 +3119,7 @@ build_constant_desc (tree exp) ...@@ -3119,7 +3119,7 @@ build_constant_desc (tree exp)
SET_SYMBOL_REF_DECL (symbol, decl); SET_SYMBOL_REF_DECL (symbol, decl);
TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1; TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol); rtl = gen_const_mem (TYPE_MODE (TREE_TYPE (exp)), symbol);
set_mem_attributes (rtl, exp, 1); set_mem_attributes (rtl, exp, 1);
set_mem_alias_set (rtl, 0); set_mem_alias_set (rtl, 0);
set_mem_alias_set (rtl, const_alias_set); set_mem_alias_set (rtl, const_alias_set);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment