https://gcc.gnu.org/g:141a592bf147c91c28de7864fa12259687e827e3

commit 141a592bf147c91c28de7864fa12259687e827e3
Author: Julian Brown <jul...@codesourcery.com>
Date:   Fri Sep 20 13:53:10 2019 -0700

    Handle references in OpenACC "private" clauses
    
            gcc/
            * gimplify.cc (localize_reductions): Rewrite references for
            OMP_CLAUSE_PRIVATE also.

Diff:
---
 gcc/ChangeLog.omp |  7 ++++++-
 gcc/gimplify.cc   | 15 +++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 93231368ff4..53b4189892b 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2019-09-20  Julian Brown  <jul...@codesourcery.com>
+
+       * gimplify.cc (localize_reductions): Rewrite references for
+       OMP_CLAUSE_PRIVATE also.
+
 2019-09-06  Julian Brown  <jul...@codesourcery.com>
 
        * gimplify.cc (gimplify_omp_for): Use for_stmt in call to
@@ -24,7 +29,7 @@
        (walk_tree_1): Adjust accordingly.
        * tree.h (OMP_CLAUSE_REDUCTION_PRIVATE_DECL): Add macro.
 
-2018-09-05  Cesar Philippidis  <ce...@codesourcery.com>
+2019-07-10  Cesar Philippidis  <ce...@codesourcery.com>
            Chung-Lin Tang  <clt...@codesourcery.com>
 
        * gimplify.cc (omp_add_variable): Enable firstprivate reduction
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index a96698ab007..69ffa9698b9 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -15168,6 +15168,21 @@ localize_reductions (tree clauses, tree body)
 
        OMP_CLAUSE_REDUCTION_PRIVATE_DECL (c) = new_var;
       }
+    else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE)
+      {
+       var = OMP_CLAUSE_DECL (c);
+
+       if (!lang_hooks.decls.omp_privatize_by_reference (var))
+         continue;
+
+       type = TREE_TYPE (TREE_TYPE (var));
+       new_var = create_tmp_var (type, IDENTIFIER_POINTER (DECL_NAME (var)));
+
+       pr.ref_var = var;
+       pr.local_var = new_var;
+
+       walk_tree (&body, localize_reductions_r, &pr, NULL);
+      }
 }

Reply via email to