aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-01-24 17:28:47 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-01-24 17:28:47 +0100
commitf1542d9aee3d96366a680a470e2754912f0e8ce7 (patch)
tree174665a92f7c4715370c978fc58ff9d4a0673587
parent556d3a2433a6e2207c6f36fe292d89d81f46f924 (diff)
downloadgcc-f1542d9aee3d96366a680a470e2754912f0e8ce7.zip
gcc-f1542d9aee3d96366a680a470e2754912f0e8ce7.tar.gz
gcc-f1542d9aee3d96366a680a470e2754912f0e8ce7.tar.bz2
re PR middle-end/83977 (ICE in simd_clone_clauses_extract, at omp-simd-clone.c:184)
PR middle-end/83977 * tree.c (free_lang_data_in_decl): Don't clear DECL_ABSTRACT_ORIGIN here. * omp-low.c (create_omp_child_function): Remove "omp declare simd" attributes from DECL_ATTRIBUTES (decl) without affecting DECL_ATTRIBUTES (current_function_decl). * omp-simd-clone.c (expand_simd_clones): Ignore DECL_ARTIFICIAL functions with non-NULL DECL_ABSTRACT_ORIGIN. * c-c++-common/gomp/pr83977-1.c: New test. * c-c++-common/gomp/pr83977-2.c: New test. * c-c++-common/gomp/pr83977-3.c: New test. * gfortran.dg/gomp/pr83977.f90: New test. From-SVN: r257023
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/omp-low.c17
-rw-r--r--gcc/omp-simd-clone.c4
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr83977-1.c19
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr83977-2.c18
-rw-r--r--gcc/testsuite/c-c++-common/gomp/pr83977-3.c21
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/pr83977.f9015
-rw-r--r--gcc/tree.c10
9 files changed, 113 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9c313b3..e52ca7c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2018-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/83977
+ * tree.c (free_lang_data_in_decl): Don't clear DECL_ABSTRACT_ORIGIN
+ here.
+ * omp-low.c (create_omp_child_function): Remove "omp declare simd"
+ attributes from DECL_ATTRIBUTES (decl) without affecting
+ DECL_ATTRIBUTES (current_function_decl).
+ * omp-simd-clone.c (expand_simd_clones): Ignore DECL_ARTIFICIAL
+ functions with non-NULL DECL_ABSTRACT_ORIGIN.
+
2018-01-24 Richard Sandiford <richard.sandiford@linaro.org>
PR tree-optimization/83979
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 3fcda29..ebbf88e 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1585,6 +1585,23 @@ create_omp_child_function (omp_context *ctx, bool task_copy)
DECL_INITIAL (decl) = make_node (BLOCK);
BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl;
DECL_ATTRIBUTES (decl) = DECL_ATTRIBUTES (current_function_decl);
+ /* Remove omp declare simd attribute from the new attributes. */
+ if (tree a = lookup_attribute ("omp declare simd", DECL_ATTRIBUTES (decl)))
+ {
+ while (tree a2 = lookup_attribute ("omp declare simd", TREE_CHAIN (a)))
+ a = a2;
+ a = TREE_CHAIN (a);
+ for (tree *p = &DECL_ATTRIBUTES (decl); *p != a;)
+ if (is_attribute_p ("omp declare simd", get_attribute_name (*p)))
+ *p = TREE_CHAIN (*p);
+ else
+ {
+ tree chain = TREE_CHAIN (*p);
+ *p = copy_node (*p);
+ p = &TREE_CHAIN (*p);
+ *p = chain;
+ }
+ }
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
= DECL_FUNCTION_SPECIFIC_OPTIMIZATION (current_function_decl);
DECL_FUNCTION_SPECIFIC_TARGET (decl)
diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index b7737a2..fbcb92b 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -1574,6 +1574,10 @@ expand_simd_clones (struct cgraph_node *node)
tree attr = lookup_attribute ("omp declare simd",
DECL_ATTRIBUTES (node->decl));
if (attr == NULL_TREE
+ /* Ignore artificial decls with an abstract origin, results of function
+ cloning, versioning etc. We want to handle certain builtins
+ with simd attribute, like __builtin_sin. */
+ || (DECL_ARTIFICIAL (node->decl) && DECL_ABSTRACT_ORIGIN (node->decl))
|| node->global.inlined_to
|| lookup_attribute ("noclone", DECL_ATTRIBUTES (node->decl)))
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 00592b7b..e0ee6b0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2018-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/83977
+ * c-c++-common/gomp/pr83977-1.c: New test.
+ * c-c++-common/gomp/pr83977-2.c: New test.
+ * c-c++-common/gomp/pr83977-3.c: New test.
+ * gfortran.dg/gomp/pr83977.f90: New test.
+
2018-01-24 Richard Sandiford <richard.sandiford@linaro.org>
PR testsuite/83889
diff --git a/gcc/testsuite/c-c++-common/gomp/pr83977-1.c b/gcc/testsuite/c-c++-common/gomp/pr83977-1.c
new file mode 100644
index 0000000..9941db4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr83977-1.c
@@ -0,0 +1,19 @@
+/* PR middle-end/83977 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2" } */
+
+struct S { int a, b, c; };
+
+#pragma omp declare simd uniform(z) linear(v:1)
+__attribute__((noinline)) static int
+foo (int x, int y, struct S z, int u, int v)
+{
+ return x + y + z.a;
+}
+
+int
+bar (int x, int y, int z)
+{
+ struct S s = { z, 1, 1 };
+ return foo (x, y, s, 0, 0);
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr83977-2.c b/gcc/testsuite/c-c++-common/gomp/pr83977-2.c
new file mode 100644
index 0000000..c3359b9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr83977-2.c
@@ -0,0 +1,18 @@
+/* PR middle-end/83977 */
+/* { dg-do compile } */
+
+void bar (void);
+
+#pragma omp declare simd uniform (b) linear(a:b)
+int
+foo (int a, int b)
+{
+ a = a + 1;
+/* This function can't be called from simd loops,
+ because it violates declare simd restrictions.
+ We shouldn't ICE on it though, nor attempt to generate
+ simd clones for the *omp_fn* functions. */
+ #pragma omp parallel
+ bar ();
+ return a;
+}
diff --git a/gcc/testsuite/c-c++-common/gomp/pr83977-3.c b/gcc/testsuite/c-c++-common/gomp/pr83977-3.c
new file mode 100644
index 0000000..00e18d8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr83977-3.c
@@ -0,0 +1,21 @@
+/* PR middle-end/83977 */
+/* { dg-do compile } */
+
+void bar (void);
+int foo (int, int) __attribute__((used));
+
+#pragma omp declare simd uniform (b) linear(a:b)
+int
+foo (int a, int b)
+{
+ a = a + 1;
+/* This function can't be called from simd loops,
+ because it violates declare simd restrictions.
+ We shouldn't ICE on it though, nor attempt to generate
+ simd clones for the *omp_fn* functions. */
+ #pragma omp parallel
+ bar ();
+ return a;
+}
+
+int foo (int, int) __attribute__((unused));
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr83977.f90 b/gcc/testsuite/gfortran.dg/gomp/pr83977.f90
new file mode 100644
index 0000000..b8ad1a7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr83977.f90
@@ -0,0 +1,15 @@
+! PR middle-end/83977
+! { dg-do compile }
+
+integer function foo (a, b)
+ integer :: a, b
+!$omp declare simd uniform(b) linear(ref(a):b)
+ a = a + 1
+! This function can't be called from simd loops,
+! because it violates declare simd restrictions.
+! We shouldn't ICE on it though, nor attempt to generate
+! simd clones for the *omp_fn* functions.
+!$omp parallel
+ call sub
+!$omp end parallel
+end
diff --git a/gcc/tree.c b/gcc/tree.c
index 63a29f4..cd68fb5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5329,16 +5329,6 @@ free_lang_data_in_decl (tree decl)
At this point, it is not needed anymore. */
DECL_SAVED_TREE (decl) = NULL_TREE;
- /* Clear the abstract origin if it refers to a method.
- Otherwise dwarf2out.c will ICE as we splice functions out of
- TYPE_FIELDS and thus the origin will not be output
- correctly. */
- if (DECL_ABSTRACT_ORIGIN (decl)
- && DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl))
- && RECORD_OR_UNION_TYPE_P
- (DECL_CONTEXT (DECL_ABSTRACT_ORIGIN (decl))))
- DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE;
-
/* Sometimes the C++ frontend doesn't manage to transform a temporary
DECL_VINDEX referring to itself into a vtable slot number as it
should. Happens with functions that are copied and then forgotten