aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2012-02-22 11:37:03 +0100
committerMartin Jambor <jamborm@gcc.gnu.org>2012-02-22 11:37:03 +0100
commitf18a7b25aaafd514f2a6e674536780bca389b608 (patch)
tree65df171e024e226db47a0d48bf7e08c34764c3f1 /gcc
parent8cfa78994aa1cfbf28b6e0fb367f34900f0eeb76 (diff)
downloadgcc-f18a7b25aaafd514f2a6e674536780bca389b608.zip
gcc-f18a7b25aaafd514f2a6e674536780bca389b608.tar.gz
gcc-f18a7b25aaafd514f2a6e674536780bca389b608.tar.bz2
re PR middle-end/51782 (-ftree-sra: Missing address-space information leads to wrong)
2012-02-22 Martin Jambor <mjambor@suse.cz> PR middle-end/51782 * emit-rtl.c (set_mem_attributes_minus_bitpos): Set address space according to the base object. From-SVN: r184463
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/emit-rtl.c39
2 files changed, 33 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d5aa911..ff81abd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-22 Martin Jambor <mjambor@suse.cz>
+
+ PR middle-end/51782
+ * emit-rtl.c (set_mem_attributes_minus_bitpos): Set address space
+ according to the base object.
+
2012-02-22 Georg-Johann Lay <avr@gjlay.de>
PR rtl-optimization/50063
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 765dd94..a95c146 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1548,6 +1548,7 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
HOST_WIDE_INT apply_bitpos = 0;
tree type;
struct mem_attrs attrs, *defattrs, *refattrs;
+ addr_space_t as;
/* It can happen that type_for_mode was given a mode for which there
is no language-level type. In which case it returns NULL, which
@@ -1681,17 +1682,29 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
MEM_NOTRAP_P (ref) = !tree_could_trap_p (t);
base = get_base_address (t);
- if (base && DECL_P (base)
- && TREE_READONLY (base)
- && (TREE_STATIC (base) || DECL_EXTERNAL (base))
- && !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 (base)
+ {
+ if (DECL_P (base)
+ && TREE_READONLY (base)
+ && (TREE_STATIC (base) || DECL_EXTERNAL (base))
+ && !TREE_THIS_VOLATILE (base))
+ MEM_READONLY_P (ref) = 1;
+
+ /* Mark static const strings readonly as well. */
+ if (TREE_CODE (base) == STRING_CST
+ && TREE_READONLY (base)
+ && TREE_STATIC (base))
+ MEM_READONLY_P (ref) = 1;
+
+ if (TREE_CODE (base) == MEM_REF
+ || TREE_CODE (base) == TARGET_MEM_REF)
+ as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (base,
+ 0))));
+ else
+ as = TYPE_ADDR_SPACE (TREE_TYPE (base));
+ }
+ else
+ as = TYPE_ADDR_SPACE (type);
/* If this expression uses it's parent's alias set, mark it such
that we won't change it. */
@@ -1830,6 +1843,8 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
attrs.align = MAX (attrs.align, obj_align);
}
}
+ else
+ as = TYPE_ADDR_SPACE (type);
/* If we modified OFFSET based on T, then subtract the outstanding
bit position offset. Similarly, increase the size of the accessed
@@ -1843,7 +1858,7 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
}
/* Now set the attributes we computed above. */
- attrs.addrspace = TYPE_ADDR_SPACE (type);
+ attrs.addrspace = as;
set_mem_attrs (ref, &attrs);
}