]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
omp-low.c: Avoid offload-target lto1 is-missing error by not-privatizing TREE_READONL...
authorTobias Burnus <tobias@codesourcery.com>
Mon, 27 Jul 2020 06:31:51 +0000 (08:31 +0200)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 22 Apr 2021 17:14:27 +0000 (10:14 -0700)
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

index 9b1d5e3763d7455a0bfd6d02f0a47e047c173814..3c7f8f986ded3aff5837b40d5b51d3d7fd2596c6 100644 (file)
@@ -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);
 }