This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix up OpenMP taskloop C++ handling (PR c++/70376)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Mar 2016 19:44:22 +0100
- Subject: [committed] Fix up OpenMP taskloop C++ handling (PR c++/70376)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
As the testcase shows, taskloop needs similar handling to task - we need
to find implicitly firstprivate variables and synthetize their copy ctors
and dtors.
2016-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/70376
* cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES
for OMP_TASKLOOP here.
(cp_genericize_r): Handle OMP_TASKLOOP like OMP_TASK, except do call
genericize_omp_for_stmt instead of cp_walk_tree on OMP_BODY.
* testsuite/libgomp.c++/pr70376.C: New test.
--- gcc/cp/cp-gimplify.c.jj 2016-03-22 09:05:32.000000000 +0100
+++ gcc/cp/cp-gimplify.c 2016-03-23 15:23:28.790585928 +0100
@@ -386,7 +386,8 @@ genericize_omp_for_stmt (tree *stmt_p, i
tree clab = begin_bc_block (bc_continue, locus);
cp_walk_tree (&OMP_FOR_BODY (stmt), cp_genericize_r, data, NULL);
- cp_walk_tree (&OMP_FOR_CLAUSES (stmt), cp_genericize_r, data, NULL);
+ if (TREE_CODE (stmt) != OMP_TASKLOOP)
+ cp_walk_tree (&OMP_FOR_CLAUSES (stmt), cp_genericize_r, data, NULL);
cp_walk_tree (&OMP_FOR_INIT (stmt), cp_genericize_r, data, NULL);
cp_walk_tree (&OMP_FOR_COND (stmt), cp_genericize_r, data, NULL);
cp_walk_tree (&OMP_FOR_INCR (stmt), cp_genericize_r, data, NULL);
@@ -1272,7 +1273,9 @@ cp_genericize_r (tree *stmt_p, int *walk
if (TREE_CODE (d) == VAR_DECL)
gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d));
}
- else if (TREE_CODE (stmt) == OMP_PARALLEL || TREE_CODE (stmt) == OMP_TASK)
+ else if (TREE_CODE (stmt) == OMP_PARALLEL
+ || TREE_CODE (stmt) == OMP_TASK
+ || TREE_CODE (stmt) == OMP_TASKLOOP)
{
struct cp_genericize_omp_taskreg omp_ctx;
tree c, decl;
@@ -1312,7 +1315,10 @@ cp_genericize_r (tree *stmt_p, int *walk
default:
break;
}
- cp_walk_tree (&OMP_BODY (stmt), cp_genericize_r, data, NULL);
+ if (TREE_CODE (stmt) == OMP_TASKLOOP)
+ genericize_omp_for_stmt (stmt_p, walk_subtrees, data);
+ else
+ cp_walk_tree (&OMP_BODY (stmt), cp_genericize_r, data, NULL);
wtd->omp_ctx = omp_ctx.outer;
splay_tree_delete (omp_ctx.variables);
}
@@ -1380,8 +1386,7 @@ cp_genericize_r (tree *stmt_p, int *walk
genericize_break_stmt (stmt_p);
else if (TREE_CODE (stmt) == OMP_FOR
|| TREE_CODE (stmt) == OMP_SIMD
- || TREE_CODE (stmt) == OMP_DISTRIBUTE
- || TREE_CODE (stmt) == OMP_TASKLOOP)
+ || TREE_CODE (stmt) == OMP_DISTRIBUTE)
genericize_omp_for_stmt (stmt_p, walk_subtrees, data);
else if ((flag_sanitize
& (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))
--- libgomp/testsuite/libgomp.c++/pr70376.C.jj 2016-03-23 15:32:59.906867697 +0100
+++ libgomp/testsuite/libgomp.c++/pr70376.C 2016-03-23 15:26:04.000000000 +0100
@@ -0,0 +1,20 @@
+// PR c++/70376
+// { dg-do link }
+
+template <typename T>
+struct A
+{
+ A() { }
+ A(const A&) { }
+ void foo() { }
+};
+
+int
+main ()
+{
+ A<int> a;
+ #pragma omp taskloop
+ for (int i = 0; i < 64; i++)
+ a.foo();
+ return 0;
+}
Jakub