aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-03-27 23:07:21 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-03-27 23:07:21 +0200
commita9e4a1a56fb8e99594b65d6640432ba29c705f3e (patch)
tree2a71ba738ce8094ef17accb652eb7b850caad814
parentaade772d8a2eeda4ea22f0ca648ebdf44d8d8c15 (diff)
downloadgcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.zip
gcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.tar.gz
gcc-a9e4a1a56fb8e99594b65d6640432ba29c705f3e.tar.bz2
re PR target/80162 (ICE on invalid code (address of register variable))
PR middle-end/80162 c-family/ * c-common.c (c_common_mark_addressable_vec): Don't set TREE_ADDRESSABLE on DECL_HARD_REGISTER. c/ * c-tree.h (c_mark_addressable): Add array_ref_p argument. * c-typeck.c (c_mark_addressable): Likewise. Look through VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE to ARRAY_TYPE. (build_array_ref): Pass true as array_ref_p to c_mark_addressable. cp/ * cp-tree.h (cxx_mark_addressable): Add array_ref_p argument. * typeck.c (cxx_mark_addressable): Likewise. Look through VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE to ARRAY_TYPE. (cp_build_array_ref): Pass true as array_ref_p to cxx_mark_addressable. testsuite/ * c-c++-common/pr80162-1.c: New test. * c-c++-common/pr80162-2.c: New test. * c-c++-common/pr80162-3.c: New test. From-SVN: r246512
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-common.c3
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c16
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/typeck.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr80162-1.c13
-rw-r--r--gcc/testsuite/c-c++-common/pr80162-2.c18
-rw-r--r--gcc/testsuite/c-c++-common/pr80162-3.c18
12 files changed, 108 insertions, 9 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 4afb4b8..0b543ec 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2017-03-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/80162
+ * c-common.c (c_common_mark_addressable_vec): Don't set
+ TREE_ADDRESSABLE on DECL_HARD_REGISTER.
+
2017-03-21 Martin Sebor <msebor@redhat.com>
PR c++/79548
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 65ffd8c..07af384 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6542,7 +6542,8 @@ c_common_mark_addressable_vec (tree t)
&& TREE_CODE (t) != PARM_DECL
&& TREE_CODE (t) != COMPOUND_LITERAL_EXPR)
return;
- TREE_ADDRESSABLE (t) = 1;
+ if (!VAR_P (t) || !DECL_HARD_REGISTER (t))
+ TREE_ADDRESSABLE (t) = 1;
}
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index f4dbeeb..08a5b9a 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2017-03-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/80162
+ * c-tree.h (c_mark_addressable): Add array_ref_p argument.
+ * c-typeck.c (c_mark_addressable): Likewise. Look through
+ VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE
+ to ARRAY_TYPE.
+ (build_array_ref): Pass true as array_ref_p to c_mark_addressable.
+
2017-03-23 Marek Polacek <polacek@redhat.com>
* c-tree.h: Remove a C_RID_YYCODE reference.
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 9428d74..5fa32a4 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -615,7 +615,7 @@ extern int same_translation_unit_p (const_tree, const_tree);
extern int comptypes (tree, tree);
extern int comptypes_check_different_types (tree, tree, bool *);
extern bool c_vla_type_p (const_tree);
-extern bool c_mark_addressable (tree);
+extern bool c_mark_addressable (tree, bool = false);
extern void c_incomplete_type_error (location_t, const_tree, const_tree);
extern tree c_type_promotes_to (tree);
extern struct c_expr default_function_array_conversion (location_t,
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index b283a21..ff239e2 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2654,7 +2654,7 @@ build_array_ref (location_t loc, tree array, tree index)
|| (COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (array)))
&& TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
{
- if (!c_mark_addressable (array))
+ if (!c_mark_addressable (array, true))
return error_mark_node;
}
/* An array that is indexed by a constant value which is not within
@@ -4755,16 +4755,26 @@ lvalue_or_else (location_t loc, const_tree ref, enum lvalue_use use)
/* Mark EXP saying that we need to be able to take the
address of it; it should not be allocated in a register.
- Returns true if successful. */
+ Returns true if successful. ARRAY_REF_P is true if this
+ is for ARRAY_REF construction - in that case we don't want
+ to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
+ it is fine to use ARRAY_REFs for vector subscripts on vector
+ register variables. */
bool
-c_mark_addressable (tree exp)
+c_mark_addressable (tree exp, bool array_ref_p)
{
tree x = exp;
while (1)
switch (TREE_CODE (x))
{
+ case VIEW_CONVERT_EXPR:
+ if (array_ref_p
+ && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
+ && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
+ return true;
+ /* FALLTHRU */
case COMPONENT_REF:
case ADDR_EXPR:
case ARRAY_REF:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ea1eaa7..1d75be5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2017-03-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/80162
+ * cp-tree.h (cxx_mark_addressable): Add array_ref_p argument.
+ * typeck.c (cxx_mark_addressable): Likewise. Look through
+ VIEW_CONVERT_EXPR unless array_ref_p and VCE is from VECTOR_TYPE
+ to ARRAY_TYPE.
+ (cp_build_array_ref): Pass true as array_ref_p to cxx_mark_addressable.
+
2017-03-24 Jason Merrill <jason@redhat.com>
PR c++/77339 - ICE with invalid use of alias template.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9f02a97..daa1a81 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6715,7 +6715,7 @@ extern void cxx_print_error_function (diagnostic_context *,
struct diagnostic_info *);
/* in typeck.c */
-extern bool cxx_mark_addressable (tree);
+extern bool cxx_mark_addressable (tree, bool = false);
extern int string_conv_p (const_tree, const_tree, int);
extern tree cp_truthvalue_conversion (tree);
extern tree condition_conversion (tree);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 4e9a1c0..79391c0 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3217,7 +3217,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
&& (TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))))
!= INTEGER_CST)))
{
- if (!cxx_mark_addressable (array))
+ if (!cxx_mark_addressable (array, true))
return error_mark_node;
}
@@ -6269,18 +6269,28 @@ unary_complex_lvalue (enum tree_code code, tree arg)
/* Mark EXP saying that we need to be able to take the
address of it; it should not be allocated in a register.
- Value is true if successful.
+ Value is true if successful. ARRAY_REF_P is true if this
+ is for ARRAY_REF construction - in that case we don't want
+ to look through VIEW_CONVERT_EXPR from VECTOR_TYPE to ARRAY_TYPE,
+ it is fine to use ARRAY_REFs for vector subscripts on vector
+ register variables.
C++: we do not allow `current_class_ptr' to be addressable. */
bool
-cxx_mark_addressable (tree exp)
+cxx_mark_addressable (tree exp, bool array_ref_p)
{
tree x = exp;
while (1)
switch (TREE_CODE (x))
{
+ case VIEW_CONVERT_EXPR:
+ if (array_ref_p
+ && TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE
+ && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (x, 0))))
+ return true;
+ /* FALLTHRU */
case ADDR_EXPR:
case COMPONENT_REF:
case ARRAY_REF:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8146499..14f6d6b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2017-03-27 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/80162
+ * c-c++-common/pr80162-1.c: New test.
+ * c-c++-common/pr80162-2.c: New test.
+ * c-c++-common/pr80162-3.c: New test.
+
PR target/80102
* g++.dg/opt/pr80102.C: New test.
diff --git a/gcc/testsuite/c-c++-common/pr80162-1.c b/gcc/testsuite/c-c++-common/pr80162-1.c
new file mode 100644
index 0000000..7d442b3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr80162-1.c
@@ -0,0 +1,13 @@
+/* PR middle-end/80162 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-msse2 -ffixed-xmm7" } */
+
+typedef int v8 __attribute__ ((vector_size (8)));
+struct U { v8 a; v8 b; };
+register struct U u asm ("xmm7");
+
+int *
+foo (int i)
+{
+ return &u.a[i]; /* { dg-error "address of \[^ \n\r]* register variable" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr80162-2.c b/gcc/testsuite/c-c++-common/pr80162-2.c
new file mode 100644
index 0000000..cb2c899
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr80162-2.c
@@ -0,0 +1,18 @@
+/* PR middle-end/80162 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-mavx2 -ffixed-xmm7" } */
+
+typedef int V __attribute__ ((vector_size (32)));
+register V u asm ("xmm7");
+
+int
+foo (int i)
+{
+ return u[i];
+}
+
+int
+bar (void)
+{
+ return u[5];
+}
diff --git a/gcc/testsuite/c-c++-common/pr80162-3.c b/gcc/testsuite/c-c++-common/pr80162-3.c
new file mode 100644
index 0000000..a600fde
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr80162-3.c
@@ -0,0 +1,18 @@
+/* PR middle-end/80162 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-mavx2 -ffixed-xmm7" } */
+
+typedef int V __attribute__ ((vector_size (32)));
+register V u asm ("xmm7");
+
+int *
+foo (int i)
+{
+ return &u[i]; /* { dg-error "address of \[^ \n\r]* register variable" } */
+}
+
+int *
+bar (void)
+{
+ return &u[5]; /* { dg-error "address of \[^ \n\r]* register variable" } */
+}