aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2019-01-11 22:03:53 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-01-11 22:03:53 +0100
commitda972c05f48637060ae3a3b121f99d1522413b82 (patch)
tree52b89022a5b5b913eb3ed34efd5c71cfade6bf23 /gcc
parentb13091dd9dbabe7fde4b112c4bfb9be729493c16 (diff)
downloadgcc-da972c05f48637060ae3a3b121f99d1522413b82.zip
gcc-da972c05f48637060ae3a3b121f99d1522413b82.tar.gz
gcc-da972c05f48637060ae3a3b121f99d1522413b82.tar.bz2
re PR middle-end/85956 (ICE in wide_int_to_tree_1, at tree.c:1549)
PR middle-end/85956 PR lto/88733 * tree-inline.h (struct copy_body_data): Add adjust_array_error_bounds field. * tree-inline.c (remap_type_1): Formatting fix. If TYPE_MAX_VALUE of ARRAY_TYPE's TYPE_DOMAIN is newly error_mark_node, replace it with a dummy "omp dummy var" variable if id->adjust_array_error_bounds. * omp-low.c (new_omp_context): Set cb.adjust_array_error_bounds. fortran/ * trans-openmp.c: Include attribs.h. (gfc_walk_alloc_comps, gfc_omp_clause_linear_ctor): Handle VAR_DECL max bound with "omp dummy var" attribute like NULL or error_mark_node - recompute number of elts independently. testsuite/ * c-c++-common/gomp/pr85956.c: New test. * g++.dg/gomp/pr88733.C: New test. From-SVN: r267858
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/fortran/ChangeLog13
-rw-r--r--gcc/fortran/trans-openmp.c19
-rw-r--r--gcc/omp-low.c1
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr85956.c12
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr88733.C29
-rw-r--r--gcc/tree-inline.c20
-rw-r--r--gcc/tree-inline.h4
9 files changed, 112 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3185dd6..0b86eec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2019-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/85956
+ PR lto/88733
+ * tree-inline.h (struct copy_body_data): Add adjust_array_error_bounds
+ field.
+ * tree-inline.c (remap_type_1): Formatting fix. If TYPE_MAX_VALUE of
+ ARRAY_TYPE's TYPE_DOMAIN is newly error_mark_node, replace it with
+ a dummy "omp dummy var" variable if id->adjust_array_error_bounds.
+ * omp-low.c (new_omp_context): Set cb.adjust_array_error_bounds.
+
2019-01-11 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/87305
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 6c5e195..c54da9d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,7 +1,16 @@
+2019-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/85956
+ PR lto/88733
+ * trans-openmp.c: Include attribs.h.
+ (gfc_walk_alloc_comps, gfc_omp_clause_linear_ctor): Handle
+ VAR_DECL max bound with "omp dummy var" attribute like NULL or
+ error_mark_node - recompute number of elts independently.
+
2019-01-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/59345
- * trans-array.c (gfc_conv_parameter_array): Temporary
+ * trans-array.c (gfc_conv_parameter_array): Temporary
arrays generated for expressions do not need to be repacked.
2019-01-10 Steven G. Kargl <kargl@gcc.gnu.org>
@@ -103,7 +112,7 @@
2019-01-01 Steven G. Kargl <kargl@gcc.gnu.org>
- * parse.c (decode_statement): Suppress "Unclassifiable statement"
+ * parse.c (decode_statement): Suppress "Unclassifiable statement"
error if previous error messages were emittes.
2019-01-01 Thomas Koenig <tkoenig@gcc.gnu.org>
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 6cbe6c7..1fdb70e 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#undef GCC_DIAG_STYLE
#define GCC_DIAG_STYLE __gcc_gfc__
+#include "attribs.h"
int ompws_flags;
@@ -297,10 +298,19 @@ gfc_walk_alloc_comps (tree decl, tree dest, tree var,
}
else
{
+ bool compute_nelts = false;
if (!TYPE_DOMAIN (type)
|| TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE
|| TYPE_MIN_VALUE (TYPE_DOMAIN (type)) == error_mark_node
|| TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == error_mark_node)
+ compute_nelts = true;
+ else if (VAR_P (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
+ {
+ tree a = DECL_ATTRIBUTES (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+ if (lookup_attribute ("omp dummy var", a))
+ compute_nelts = true;
+ }
+ if (compute_nelts)
{
tem = fold_build2 (EXACT_DIV_EXPR, sizetype,
TYPE_SIZE_UNIT (type),
@@ -912,11 +922,20 @@ gfc_omp_clause_linear_ctor (tree clause, tree dest, tree src, tree add)
&& (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
|| !POINTER_TYPE_P (type)))
{
+ bool compute_nelts = false;
gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
if (!TYPE_DOMAIN (type)
|| TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == NULL_TREE
|| TYPE_MIN_VALUE (TYPE_DOMAIN (type)) == error_mark_node
|| TYPE_MAX_VALUE (TYPE_DOMAIN (type)) == error_mark_node)
+ compute_nelts = true;
+ else if (VAR_P (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
+ {
+ tree a = DECL_ATTRIBUTES (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+ if (lookup_attribute ("omp dummy var", a))
+ compute_nelts = true;
+ }
+ if (compute_nelts)
{
nelems = fold_build2 (EXACT_DIV_EXPR, sizetype,
TYPE_SIZE_UNIT (type),
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 84a6add..1043b6b 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -872,6 +872,7 @@ new_omp_context (gimple *stmt, omp_context *outer_ctx)
}
ctx->cb.decl_map = new hash_map<tree, tree>;
+ ctx->cb.adjust_array_error_bounds = true;
return ctx;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8a031e1..f991df8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2019-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/85956
+ PR lto/88733
+ * c-c++-common/gomp/pr85956.c: New test.
+ * g++.dg/gomp/pr88733.C: New test.
+
2019-01-11 Tobias Burnus <burnus@net-b.de>
PR C++/88114
diff --git a/gcc/testsuite/c-c++-common/gomp/pr85956.c b/gcc/testsuite/c-c++-common/gomp/pr85956.c
new file mode 100644
index 0000000..bfbf1e3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr85956.c
@@ -0,0 +1,12 @@
+/* PR middle-end/85956 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -Wall" } */
+
+void
+foo (int n, void *p)
+{
+ int (*a)[n] = (int (*)[n]) p;
+ #pragma omp parallel shared(a) default(none)
+ #pragma omp master
+ a[-1][-1] = 42; /* { dg-warning "array subscript -1 is below array bounds" } */
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr88733.C b/gcc/testsuite/g++.dg/gomp/pr88733.C
new file mode 100644
index 0000000..f80de7e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr88733.C
@@ -0,0 +1,29 @@
+// PR lto/88733
+// { dg-do compile }
+// { dg-additional-options "-flto -ffat-lto-objects" { target lto } }
+
+struct A { int f; } a;
+
+__attribute__((noipa)) void
+bar (A **x, int)
+{
+ x[0] = &a;
+}
+
+int
+foo (int n)
+{
+ int g;
+ A *j[n];
+ bar (j, n);
+#pragma omp parallel
+#pragma omp single
+ g = j[0]->f;
+ return g;
+}
+
+int
+main ()
+{
+ foo (0);
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 75d1df1..8862077 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -523,11 +523,27 @@ remap_type_1 (tree type, copy_body_data *id)
if (TYPE_MAIN_VARIANT (new_tree) != new_tree)
{
- gcc_checking_assert (TYPE_DOMAIN (type) == TYPE_DOMAIN (TYPE_MAIN_VARIANT (type)));
+ gcc_checking_assert (TYPE_DOMAIN (type)
+ == TYPE_DOMAIN (TYPE_MAIN_VARIANT (type)));
TYPE_DOMAIN (new_tree) = TYPE_DOMAIN (TYPE_MAIN_VARIANT (new_tree));
}
else
- TYPE_DOMAIN (new_tree) = remap_type (TYPE_DOMAIN (new_tree), id);
+ {
+ TYPE_DOMAIN (new_tree) = remap_type (TYPE_DOMAIN (new_tree), id);
+ /* For array bounds where we have decided not to copy over the bounds
+ variable which isn't used in OpenMP/OpenACC region, change them to
+ an uninitialized VAR_DECL temporary. */
+ if (TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) == error_mark_node
+ && id->adjust_array_error_bounds
+ && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
+ {
+ tree v = create_tmp_var (TREE_TYPE (TYPE_DOMAIN (new_tree)));
+ DECL_ATTRIBUTES (v)
+ = tree_cons (get_identifier ("omp dummy var"), NULL_TREE,
+ DECL_ATTRIBUTES (v));
+ TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) = v;
+ }
+ }
break;
case RECORD_TYPE:
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index dc25c39..f09e2b4 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -122,6 +122,10 @@ struct copy_body_data
/* True if the location information will need to be reset. */
bool reset_location;
+ /* Replace error_mark_node as upper bound of array types with
+ an uninitialized VAR_DECL temporary. */
+ bool adjust_array_error_bounds;
+
/* A function to be called when duplicating BLOCK nodes. */
void (*transform_lang_insert_block) (tree);