summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-04 16:38:50 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-04 16:38:50 +0000
commit499e2be8a43f0dc11f13e1d3e7a86cf93df5962c (patch)
treec8294be6e931cc9efefd835049d806e5c39a7f5a /gcc
parentd348be20025afdcce1d1fa3b60b907da39ecb028 (diff)
downloadgcc-499e2be8a43f0dc11f13e1d3e7a86cf93df5962c.tar.gz
* lto.c (hash_canonical_type): Use tree_code_for_canonical_type_merging.
* tree.h (tree_code_for_canonical_type_merging): New function. * tree.c (gimple_canonical_types_compatible_p): Use tree_code_for_canonical_type_merging.. * gcc.dg/lto/c-compatible-types_0.c: New testcase. * gcc.dg/lto/c-compatible-types_1.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224135 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/lto/ChangeLog4
-rw-r--r--gcc/lto/lto.c2
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.dg/lto/c-compatible-types_0.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/c-compatible-types_1.c19
-rw-r--r--gcc/tree.c3
-rw-r--r--gcc/tree.h21
8 files changed, 86 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 78d46132672..a5ca74fa784 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-04 Jan Hubicka <hubicka@ucw.cz>
+
+ * tree.h (tree_code_for_canonical_type_merging): New function.
+ * tree.c (gimple_canonical_types_compatible_p): Use
+ tree_code_for_canonical_type_merging..
+
2015-06-04 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR c++/66192
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index db0214beb31..2d6ddf5cdc7 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-04 Jan Hubicka <hubicka@ucw.cz>
+
+ * lto.c (hash_canonical_type): Use tree_code_for_canonical_type_merging.
+
2015-06-03 Jan Hubicka <hubicka@ucw.cz>
* lto.c (iterative_hash_canonical_type,
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 75774a10600..498eb80450f 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -319,7 +319,7 @@ hash_canonical_type (tree type)
smaller sets; when searching for existing matching types to merge,
only existing types having the same features as the new type will be
checked. */
- hstate.add_int (TREE_CODE (type));
+ hstate.add_int (tree_code_for_canonical_type_merging (TREE_CODE (type)));
hstate.add_int (TYPE_MODE (type));
/* Incorporate common features of numerical types. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c867eeca385..a64729a648f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2015-06-04 Jan Hubicka <hubicka@ucw.cz>
+
+ * gcc.dg/lto/c-compatible-types_0.c: New testcase.
+ * gcc.dg/lto/c-compatible-types_1.c: New testcase.
+
+2015-06-03 Jan Hubicka <hubicka@ucw.cz>
+
+ * lto.c (iterative_hash_canonical_type,
+ gimple_register_canonical_type): only hash main variants of types
+
2015-06-04 Sandra Loosemore <sandra@codesourcery.com>
* gcc.target/aarch64/advsimd-intrinsics/advsimd-intrinsics.exp:
diff --git a/gcc/testsuite/gcc.dg/lto/c-compatible-types_0.c b/gcc/testsuite/gcc.dg/lto/c-compatible-types_0.c
new file mode 100644
index 00000000000..ca33de21869
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/c-compatible-types_0.c
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+/* { dg-skip-if "require -fno-short-enums to work" {target short_enums} } */
+
+/* By C standard Each enumerated type shall be compatible with char, a signed
+ integer, type, or an unsigned integer type. The choice of type is
+ implementation-defined. Check that enum and unsigned int match. */
+unsigned int a;
+unsigned int *b;
+void t();
+
+void reset ()
+{
+ asm("":"=r"(a):"0"(0));
+}
+int
+main()
+{
+ asm("":"=r"(a):"0"(1));
+ asm("":"=r"(b):"0"(&a));
+ t();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/c-compatible-types_1.c b/gcc/testsuite/gcc.dg/lto/c-compatible-types_1.c
new file mode 100644
index 00000000000..ff0d16e3111
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/c-compatible-types_1.c
@@ -0,0 +1,19 @@
+enum a {test1, test2};
+enum a a;
+enum a *b;
+
+void reset (void);
+
+void
+t()
+{
+ if (a != test2)
+ __builtin_abort ();
+ if (*b != test2)
+ __builtin_abort ();
+ reset ();
+ if (a != test1)
+ __builtin_abort ();
+ if (*b != test1)
+ __builtin_abort ();
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index b0aeb74f64d..b3244050d7a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -12930,7 +12930,8 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
/* Can't be the same type if the types don't have the same code. */
- if (TREE_CODE (t1) != TREE_CODE (t2))
+ if (tree_code_for_canonical_type_merging (TREE_CODE (t1))
+ != tree_code_for_canonical_type_merging (TREE_CODE (t2)))
return false;
/* Qualifiers do not matter for canonical type comparison purposes. */
diff --git a/gcc/tree.h b/gcc/tree.h
index 732a61c2131..ca5e68100da 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4598,6 +4598,27 @@ extern int tree_map_base_marked_p (const void *);
extern void DEBUG_FUNCTION verify_type (const_tree t);
extern bool gimple_canonical_types_compatible_p (const_tree, const_tree,
bool trust_type_canonical = true);
+/* Return simplified tree code of type that is used for canonical type merging. */
+inline enum tree_code
+tree_code_for_canonical_type_merging (enum tree_code code)
+{
+ /* By C standard, each enumerated type shall be compatible with char,
+ a signed integer, or an unsigned integer. The choice of type is
+ implementation defined (in our case it depends on -fshort-enum).
+
+ For this reason we make no distinction between ENUMERAL_TYPE and INTEGER
+ type and compare only by their signedness and precision. */
+ if (code == ENUMERAL_TYPE)
+ return INTEGER_TYPE;
+ /* To allow inter-operability between languages having references and
+ C, we consider reference types and pointers alike. Note that this is
+ not strictly necessary for C-Fortran 2008 interoperability because
+ Fortran define C_PTR type that needs to be compatible with C pointers
+ and we handle this one as ptr_type_node. */
+ if (code == REFERENCE_TYPE)
+ return POINTER_TYPE;
+ return code;
+}
#define tree_map_eq tree_map_base_eq
extern unsigned int tree_map_hash (const void *);