aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-11-14 01:46:16 +0100
committerJakub Jelinek <jakub@redhat.com>2020-11-14 01:46:16 +0100
commita4dd85e01599890286d9af5b106a1ab20e51169e (patch)
tree3ea1bdeca840ecb5e7708bb78903693eeae47cf8 /gcc/gimplify.c
parent77f67db2a4709388b905397421bd3a851fbbf884 (diff)
downloadgcc-a4dd85e01599890286d9af5b106a1ab20e51169e.zip
gcc-a4dd85e01599890286d9af5b106a1ab20e51169e.tar.gz
gcc-a4dd85e01599890286d9af5b106a1ab20e51169e.tar.bz2
openmp: Add support for non-VLA {,first}private allocate on omp task
This patch adds support for custom allocators on private/firstprivate clauses for task (and taskloop) constructs. Private didn't need anything special, but firstprivate if it is passed by reference needs the GOMP_alloc calls in the copyfn and GOMP_free in the task body. 2020-11-14 Jakub Jelinek <jakub@redhat.com> * gimplify.c (gimplify_omp_for): Add OMP_CLAUSE_ALLOCATE_ALLOCATOR decls as firstprivate on task clauses even when allocate clause decl is not lastprivate. * omp-low.c (install_var_field): Don't dereference omp_is_reference types if mask is 33 rather than 1. (scan_sharing_clauses): Populate allocate_map even for task constructs. For now remove it back for variables mentioned in reduction and in_reduction clauses on task/taskloop constructs or on VLA task firstprivates. For firstprivate on task construct, install the var field into field_map with by_ref and 33 instead of false and 1 if mentioned in allocate clause. (lower_private_allocate): Set TREE_THIS_NOTRAP on the created MEM_REF. (lower_rec_input_clauses): Handle allocate for task firstprivatized non-VLA variables. (create_task_copyfn): Likewise. * testsuite/libgomp.c-c++-common/allocate-1.c (struct S): New type. (foo): Add tests for non-VLA private and firstprivate clauses on omp task. (bar): Likewise. Remove taking of address from private/firstprivate variables. * testsuite/libgomp.c++/allocate-1.C (struct S): New type. (foo): Add p, q, px and s arguments. Add tests for array reductions and for non-VLA private and firstprivate clauses on omp task. (bar): Removed. (main): Adjust foo caller. Don't call bar.
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b861e17..2566ec7 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -12463,22 +12463,22 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
/* Allocate clause we duplicate on task and inner taskloop
if the decl is lastprivate, otherwise just put on task. */
case OMP_CLAUSE_ALLOCATE:
+ if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
+ && DECL_P (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)))
+ {
+ /* Additionally, put firstprivate clause on task
+ for the allocator if it is not constant. */
+ *gtask_clauses_ptr
+ = build_omp_clause (OMP_CLAUSE_LOCATION (c),
+ OMP_CLAUSE_FIRSTPRIVATE);
+ OMP_CLAUSE_DECL (*gtask_clauses_ptr)
+ = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c);
+ gtask_clauses_ptr = &OMP_CLAUSE_CHAIN (*gtask_clauses_ptr);
+ }
if (lastprivate_uids
&& bitmap_bit_p (lastprivate_uids,
DECL_UID (OMP_CLAUSE_DECL (c))))
{
- if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
- && DECL_P (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)))
- {
- /* Additionally, put firstprivate clause on task
- for the allocator if it is not constant. */
- *gtask_clauses_ptr
- = build_omp_clause (OMP_CLAUSE_LOCATION (c),
- OMP_CLAUSE_FIRSTPRIVATE);
- OMP_CLAUSE_DECL (*gtask_clauses_ptr)
- = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c);
- gtask_clauses_ptr = &OMP_CLAUSE_CHAIN (*gtask_clauses_ptr);
- }
*gfor_clauses_ptr = c;
gfor_clauses_ptr = &OMP_CLAUSE_CHAIN (c);
*gtask_clauses_ptr = copy_node (c);