From: Tobias Burnus Date: Mon, 27 Jul 2020 06:31:51 +0000 (+0200) Subject: omp-low.c: Avoid offload-target lto1 is-missing error by not-privatizing TREE_READONL... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b2e24f0481bc8269a8e6e356e560d011b52909e;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 9b1d5e3763d7..3c7f8f986ded 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -10128,7 +10128,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); } } @@ -10143,7 +10145,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); }