diff options
author | Richard Biener <rguenther@suse.de> | 2019-04-01 07:16:38 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-04-01 07:16:38 +0000 |
commit | 2a82beaa820410600441f36e49e91a3a18e04fc5 (patch) | |
tree | 490cacb54993cc607e3f50a0411bec1e99e8f8b3 /gcc/c/c-objc-common.c | |
parent | acf8e57ae2ee28123fc04ce26635963751851824 (diff) | |
download | gcc-2a82beaa820410600441f36e49e91a3a18e04fc5.zip gcc-2a82beaa820410600441f36e49e91a3a18e04fc5.tar.gz gcc-2a82beaa820410600441f36e49e91a3a18e04fc5.tar.bz2 |
re PR c/71598 (Wrong optimization with aliasing enums)
2019-04-01 Richard Biener <rguenther@suse.de>
PR c/71598
* gimple.c: Include langhooks.h.
(gimple_get_alias_set): Treat enumeral types as the underlying
integer type.
c/
* c-tree.h (c_get_alias_set): Declare.
* c-objc-common.h (LANG_HOOKS_GET_ALIAS_SET): Use c_get_alias_set.
* c-objc-common.c (c_get_alias_set): Treat enumeral types
as the underlying integer type.
* gcc.dg/torture/pr71598-1.c: New testcase.
* gcc.dg/torture/pr71598-2.c: Likewise.
* gcc.dg/torture/pr71598-3.c: Likewise.
From-SVN: r270052
Diffstat (limited to 'gcc/c/c-objc-common.c')
-rw-r--r-- | gcc/c/c-objc-common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c index 21ca7e6..2b76737 100644 --- a/gcc/c/c-objc-common.c +++ b/gcc/c/c-objc-common.c @@ -265,3 +265,22 @@ c_vla_unspec_p (tree x, tree fn ATTRIBUTE_UNUSED) { return c_vla_type_p (x); } + +/* Special routine to get the alias set of T for C. */ + +alias_set_type +c_get_alias_set (tree t) +{ + /* Allow aliasing between enumeral types and the underlying + integer type. This is required since those are compatible types. */ + if (TREE_CODE (t) == ENUMERAL_TYPE) + { + tree t1 = c_common_type_for_size (tree_to_uhwi (TYPE_SIZE (t)), + /* short-cut commoning to signed + type. */ + false); + return get_alias_set (t1); + } + + return c_common_get_alias_set (t); +} |