diff options
author | Tom de Vries <tom@codesourcery.com> | 2011-10-13 09:54:50 +0000 |
---|---|---|
committer | Tom de Vries <tom@codesourcery.com> | 2011-10-13 09:54:50 +0000 |
commit | 96b488fa4acd559f2fc4d29b87a4187666b58af3 (patch) | |
tree | 632f11e927fc77c78227669b4d1bc7c536ad109b /gcc/emit-rtl.c | |
parent | 58d5761e52420f7e2073d5ab8af0fdb46f3135c5 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@179896 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r-- | gcc/emit-rtl.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index dae7669297a..8465237da60 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)) |