From ba30e50da297aae475d10e95cd8d391e1e4dde17 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 13 Oct 2011 09:54:50 +0000 Subject: emit-rtl.c (set_mem_attributes_minus_bitpos): Set MEM_READONLY_P for static const strings. 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. From-SVN: r179896 --- gcc/emit-rtl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/emit-rtl.c') 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)) -- cgit v1.1