aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-10-12 19:30:45 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-10-12 19:30:45 +0200
commit1688485d3757ea2746e92d066c9f9041d6267350 (patch)
tree5c67ed8774b2a41883bafdaa5fdb6e6dae0549bb
parent13d7c032ddb77ba0623d27dcedfb7d55751a83cb (diff)
backport: re PR middle-end/86542 (wrong-code for collapsed taskloop which needs omp_cpyfn)
Backported from mainline 2018-07-17 Jakub Jelinek <jakub@redhat.com> PR middle-end/86542 * omp-low.c (create_task_copyfn): Copy over also fields corresponding to _looptemp_ clauses, other than the first two. * testsuite/libgomp.c++/pr86542.C: New test. From-SVN: r265118
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/omp-low.c15
-rw-r--r--libgomp/ChangeLog3
-rw-r--r--libgomp/testsuite/libgomp.c++/pr86542.C37
4 files changed, 58 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5c5459ed8a0..0af69b9be55 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -3,6 +3,10 @@
Backported from mainline
2018-07-17 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/86542
+ * omp-low.c (create_task_copyfn): Copy over also fields corresponding
+ to _looptemp_ clauses, other than the first two.
+
PR middle-end/86539
* gimplify.c (gimplify_omp_for): Ensure taskloop firstprivatized init
and cond temporaries don't have reference type if iterator has
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 04cbf741667..304cde82194 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -15393,6 +15393,7 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
splay_tree_node n;
struct omp_taskcopy_context tcctx;
location_t loc = gimple_location (task_stmt);
+ size_t looptempno = 0;
child_fn = gimple_omp_task_copy_fn (task_stmt);
child_cfun = DECL_STRUCT_FUNCTION (child_fn);
@@ -15506,6 +15507,15 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
append_to_statement_list (t, &list);
break;
+ case OMP_CLAUSE__LOOPTEMP_:
+ /* Fields for first two _looptemp_ clauses are initialized by
+ GOMP_taskloop*, the rest are handled like firstprivate. */
+ if (looptempno < 2)
+ {
+ looptempno++;
+ break;
+ }
+ /* FALLTHRU */
case OMP_CLAUSE_FIRSTPRIVATE:
decl = OMP_CLAUSE_DECL (c);
if (is_variable_sized (decl))
@@ -15531,7 +15541,10 @@ create_task_copyfn (gomp_task *task_stmt, omp_context *ctx)
src = decl;
dst = build_simple_mem_ref_loc (loc, arg);
dst = omp_build_component_ref (dst, f);
- t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src);
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE__LOOPTEMP_)
+ t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
+ else
+ t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src);
append_to_statement_list (t, &list);
break;
case OMP_CLAUSE_PRIVATE:
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 45357816aec..011ea233ff4 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -3,6 +3,9 @@
Backported from mainline
2018-07-17 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/86542
+ * testsuite/libgomp.c++/pr86542.C: New test.
+
PR middle-end/86539
* testsuite/libgomp.c++/pr86539.C: New test.
diff --git a/libgomp/testsuite/libgomp.c++/pr86542.C b/libgomp/testsuite/libgomp.c++/pr86542.C
new file mode 100644
index 00000000000..a8ebe574012
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr86542.C
@@ -0,0 +1,37 @@
+// PR middle-end/86542
+
+struct S { int s; S (); ~S (); S (const S &); };
+S s;
+
+S::S ()
+{
+}
+
+S::~S ()
+{
+}
+
+S::S (const S &x)
+{
+ s = x.s;
+}
+
+__attribute__((noinline, noclone)) void
+foo (int i, int j, int k, S s)
+{
+ if (i != 0 || j != 0 || k != 0 || s.s != 12)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ volatile int inc = 16, jnc = 16, knc = 16;
+ s.s = 12;
+ #pragma omp taskloop collapse (3) firstprivate (s)
+ for (int i = 0; i < 16; i += inc)
+ for (int j = 0; j < 16; j += jnc)
+ for (int k = 0; k < 16; k += knc)
+ foo (i, j, k, s);
+ return 0;
+}