From 9eb0117bd6c51290ce4d0f1313c0f368185a699d Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 27 Jul 2020 08:31:51 +0200 Subject: [PATCH] omp-low.c: Avoid offload-target lto1 is-missing error by not-privatizing TREE_READONLY vars Fixes issue exposed by testsuite/libgomp.oacc-fortran/privatized-ref-2.f90 gcc/ChangeLog: * omp-low.c (oacc_record_private_var_clauses, oacc_record_vars_in_bind): Do not privatize read-only static/extern variables. --- gcc/omp-low.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 096036353506..bd3866c4d2ed 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -9813,7 +9813,9 @@ oacc_record_private_var_clauses (omp_context *ctx, tree clauses) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE) { tree decl = OMP_CLAUSE_DECL (c); - if (VAR_P (decl) && TREE_ADDRESSABLE (decl)) + if (VAR_P (decl) && TREE_ADDRESSABLE (decl) + && !(TREE_READONLY (decl) + && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))) ctx->oacc_addressable_var_decls->safe_push (decl); } } @@ -9828,7 +9830,8 @@ oacc_record_vars_in_bind (omp_context *ctx, tree bindvars) return; for (tree v = bindvars; v; v = DECL_CHAIN (v)) - if (VAR_P (v) && TREE_ADDRESSABLE (v)) + if (VAR_P (v) && TREE_ADDRESSABLE (v) + && !(TREE_READONLY (v) && (TREE_STATIC (v) || DECL_EXTERNAL (v)))) ctx->oacc_addressable_var_decls->safe_push (v); } -- 2.47.2