From cab98a0d561a6939efccec624f5638afd5edb6de Mon Sep 17 00:00:00 2001 From: vries Date: Thu, 13 Oct 2011 09:54:50 +0000 Subject: [PATCH] 2011-10-13 Tom de Vries * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179896 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/emit-rtl.c | 6 ++++++ gcc/varasm.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 01d2135..c8c7ef8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-10-13 Tom de Vries + + * 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 PR tree-optimization/50698 diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index dae7669..8465237 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1696,6 +1696,12 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, && !TREE_THIS_VOLATILE (base)) 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 that we won't change it. */ if (component_uses_parent_alias_set (t)) diff --git a/gcc/varasm.c b/gcc/varasm.c index 94e3111..d0de213 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3119,7 +3119,7 @@ build_constant_desc (tree exp) SET_SYMBOL_REF_DECL (symbol, decl); 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_alias_set (rtl, 0); set_mem_alias_set (rtl, const_alias_set); -- 2.7.4