aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-09-15 09:24:47 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-09-15 09:24:47 +0200
commit972da557463ec946a31577294764a186b9821012 (patch)
treed0ab3a41af83955eccee4b164c805262939e022d /gcc/gimplify.c
parentf9d2def016410a2095df6b399097b482f82064a5 (diff)
downloadgcc-972da557463ec946a31577294764a186b9821012.zip
gcc-972da557463ec946a31577294764a186b9821012.tar.gz
gcc-972da557463ec946a31577294764a186b9821012.tar.bz2
OpenMP/Fortran: Fix (re)mapping of allocatable/pointer arrays [PR96668]
gcc/cp/ChangeLog: PR fortran/96668 * cp-gimplify.c (cxx_omp_finish_clause): Add bool openacc arg. * cp-tree.h (cxx_omp_finish_clause): Likewise * semantics.c (handle_omp_for_class_iterator): Update call. gcc/fortran/ChangeLog: PR fortran/96668 * trans.h (gfc_omp_finish_clause): Add bool openacc arg. * trans-openmp.c (gfc_omp_finish_clause): Ditto. Use GOMP_MAP_ALWAYS_POINTER with PSET for pointers. (gfc_trans_omp_clauses): Like the latter and also if the always modifier is used. gcc/ChangeLog: PR fortran/96668 * gimplify.c (gimplify_omp_for): Add 'bool openacc' argument; update omp_finish_clause calls. (gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses, gimplify_expr, gimplify_omp_loop): Update omp_finish_clause and/or gimplify_for calls. * langhooks-def.h (lhd_omp_finish_clause): Add bool openacc arg. * langhooks.c (lhd_omp_finish_clause): Likewise. * langhooks.h (lhd_omp_finish_clause): Likewise. * omp-low.c (scan_sharing_clauses): Keep GOMP_MAP_TO_PSET cause for 'declare target' vars. include/ChangeLog: PR fortran/96668 * gomp-constants.h (GOMP_MAP_ALWAYS_POINTER_P): Define. libgomp/ChangeLog: PR fortran/96668 * libgomp.h (struct target_var_desc): Add has_null_ptr_assoc member. * target.c (gomp_map_vars_existing): Add always_to_flag flag. (gomp_map_vars_existing): Update call to it. (gomp_map_fields_existing): Likewise (gomp_map_vars_internal): Update PSET handling such that if a nullptr is now allocated or if GOMP_MAP_POINTER is used PSET is updated and pointer remapped. (GOMP_target_enter_exit_data): Hanlde GOMP_MAP_ALWAYS_POINTER like GOMP_MAP_POINTER. * testsuite/libgomp.fortran/map-alloc-ptr-1.f90: New test. * testsuite/libgomp.fortran/map-alloc-ptr-2.f90: New test.
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 23d0e25..2dea03cc 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10123,13 +10123,15 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
OMP_CLAUSE_CHAIN (clause) = nc;
struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
gimplify_omp_ctxp = ctx->outer_context;
- lang_hooks.decls.omp_finish_clause (nc, pre_p);
+ lang_hooks.decls.omp_finish_clause (nc, pre_p,
+ (ctx->region_type & ORT_ACC) != 0);
gimplify_omp_ctxp = ctx;
}
*list_p = clause;
struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
gimplify_omp_ctxp = ctx->outer_context;
- lang_hooks.decls.omp_finish_clause (clause, pre_p);
+ lang_hooks.decls.omp_finish_clause (clause, pre_p,
+ (ctx->region_type & ORT_ACC) != 0);
if (gimplify_omp_ctxp)
for (; clause != chain; clause = OMP_CLAUSE_CHAIN (clause))
if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
@@ -10539,7 +10541,9 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p,
OMP_CLAUSE_SET_MAP_KIND (nc, GOMP_MAP_TOFROM);
OMP_CLAUSE_DECL (nc) = decl;
OMP_CLAUSE_CHAIN (c) = nc;
- lang_hooks.decls.omp_finish_clause (nc, pre_p);
+ lang_hooks.decls.omp_finish_clause (nc, pre_p,
+ (ctx->region_type
+ & ORT_ACC) != 0);
while (1)
{
OMP_CLAUSE_MAP_IN_REDUCTION (nc) = 1;
@@ -11040,6 +11044,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
int i;
bitmap has_decl_expr = NULL;
enum omp_region_type ort = ORT_WORKSHARE;
+ bool openacc = TREE_CODE (*expr_p) == OACC_LOOP;
orig_for_stmt = for_stmt = *expr_p;
@@ -11147,7 +11152,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
OMP_CLAUSE_CHAIN (c) = OMP_FOR_CLAUSES (for_stmt);
OMP_FOR_CLAUSES (for_stmt) = c;
OMP_CLAUSE_CODE (*pc) = OMP_CLAUSE_FIRSTPRIVATE;
- lang_hooks.decls.omp_finish_clause (*pc, pre_p);
+ lang_hooks.decls.omp_finish_clause (*pc, pre_p, openacc);
}
else
{
@@ -11159,7 +11164,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
OMP_CLAUSE_DECL (c) = OMP_CLAUSE_DECL (*pc);
OMP_CLAUSE_CHAIN (c) = *pc;
*pc = c;
- lang_hooks.decls.omp_finish_clause (*pc, pre_p);
+ lang_hooks.decls.omp_finish_clause (*pc, pre_p, openacc);
}
tree c = build_omp_clause (UNKNOWN_LOCATION,
OMP_CLAUSE_FIRSTPRIVATE);
@@ -12115,7 +12120,8 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
= build_omp_clause (OMP_CLAUSE_LOCATION (c),
OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (*gtask_clauses_ptr) = OMP_CLAUSE_DECL (c);
- lang_hooks.decls.omp_finish_clause (*gtask_clauses_ptr, NULL);
+ lang_hooks.decls.omp_finish_clause (*gtask_clauses_ptr, NULL,
+ openacc);
gtask_clauses_ptr = &OMP_CLAUSE_CHAIN (*gtask_clauses_ptr);
*gforo_clauses_ptr = c;
gforo_clauses_ptr = &OMP_CLAUSE_CHAIN (c);
@@ -12154,7 +12160,8 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
= build_omp_clause (OMP_CLAUSE_LOCATION (c),
OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (*gtask_clauses_ptr) = OMP_CLAUSE_DECL (c);
- lang_hooks.decls.omp_finish_clause (*gtask_clauses_ptr, NULL);
+ lang_hooks.decls.omp_finish_clause (*gtask_clauses_ptr, NULL,
+ openacc);
gtask_clauses_ptr = &OMP_CLAUSE_CHAIN (*gtask_clauses_ptr);
OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c) = 1;
*gforo_clauses_ptr = build_omp_clause (OMP_CLAUSE_LOCATION (c),
@@ -12535,7 +12542,7 @@ gimplify_omp_loop (tree *expr_p, gimple_seq *pre_p)
*pc = build_omp_clause (OMP_CLAUSE_LOCATION (c),
OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (*pc) = OMP_CLAUSE_DECL (c);
- lang_hooks.decls.omp_finish_clause (*pc, NULL);
+ lang_hooks.decls.omp_finish_clause (*pc, NULL, false);
pc = &OMP_CLAUSE_CHAIN (*pc);
}
*pc = copy_node (c);
@@ -12546,7 +12553,7 @@ gimplify_omp_loop (tree *expr_p, gimple_seq *pre_p)
if (pass != last)
OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (*pc) = 1;
else
- lang_hooks.decls.omp_finish_clause (*pc, NULL);
+ lang_hooks.decls.omp_finish_clause (*pc, NULL, false);
OMP_CLAUSE_LASTPRIVATE_LOOP_IV (*pc) = 0;
}
pc = &OMP_CLAUSE_CHAIN (*pc);