On Tue, Aug 31, 2021 at 04:28:19PM +0200, Thomas Schwinge wrote:
> >From fb29fe81b4c8e880b32d68351385d8a42c97934b Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge <tho...@codesourcery.com>
> Date: Wed, 29 May 2019 18:59:46 +0200
> Subject: [PATCH] [OMP] Standardize on 'omp_privatize_by_reference'
> 
> ... instead of 'omp_is_reference' vs.
> 'lang_hooks.decls.omp_privatize_by_reference'.
> 
>       gcc/
>       * omp-general.h (omp_is_reference): Rename to...
>       (omp_privatize_by_reference): ... this.  Adjust all users...
>       * omp-general.c: ... here, ...
>       * gimplify.c: ... here, ...
>       * omp-expand.c: ... here, ...
>       * omp-low.c: ... here.

Ok for trunk.

> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index 070d0e4df45..cab4089192a 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -1831,7 +1831,8 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
>             gimplify_and_add (init, seq_p);
>             ggc_free (init);
>             /* Clear TREE_READONLY if we really have an initialization.  */
> -           if (!DECL_INITIAL (decl) && !omp_is_reference (decl))
> +           if (!DECL_INITIAL (decl)
> +               && !omp_privatize_by_reference (decl))
>               TREE_READONLY (decl) = 0;
>           }
>         else
> @@ -7064,7 +7065,7 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree 
> decl, unsigned int flags)
>       omp_notice_variable (ctx, TYPE_SIZE_UNIT (TREE_TYPE (decl)), true);
>      }
>    else if ((flags & (GOVD_MAP | GOVD_LOCAL)) == 0
> -        && lang_hooks.decls.omp_privatize_by_reference (decl))
> +        && omp_privatize_by_reference (decl))
>      {
>        omp_firstprivatize_type_sizes (ctx, TREE_TYPE (decl));
>  
> @@ -7322,7 +7323,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree 
> decl, unsigned flags)
>    bool declared = is_oacc_declared (decl);
>    tree type = TREE_TYPE (decl);
>  
> -  if (lang_hooks.decls.omp_privatize_by_reference (decl))
> +  if (omp_privatize_by_reference (decl))
>      type = TREE_TYPE (type);
>  
>    /* For Fortran COMMON blocks, only used variables in those blocks are
> @@ -7586,7 +7587,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree 
> decl, bool in_code)
>             tree type = TREE_TYPE (decl);
>  
>             if (gimplify_omp_ctxp->target_firstprivatize_array_bases
> -               && lang_hooks.decls.omp_privatize_by_reference (decl))
> +               && omp_privatize_by_reference (decl))
>               type = TREE_TYPE (type);
>             if (!lang_hooks.types.omp_mappable_type (type))
>               {
> @@ -7660,7 +7661,7 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree 
> decl, bool in_code)
>         n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t);
>         n2->value |= GOVD_SEEN;
>       }
> -      else if (lang_hooks.decls.omp_privatize_by_reference (decl)
> +      else if (omp_privatize_by_reference (decl)
>              && TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl)))
>              && (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (decl))))
>                  != INTEGER_CST))
> @@ -7785,7 +7786,7 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree 
> decl, bool copyprivate)
>         if (copyprivate)
>           return true;
>  
> -       if (lang_hooks.decls.omp_privatize_by_reference (decl))
> +       if (omp_privatize_by_reference (decl))
>           return false;
>  
>         /* Treat C++ privatized non-static data members outside
> @@ -10373,7 +10374,7 @@ omp_shared_to_firstprivate_optimizable_decl_p (tree 
> decl)
>    HOST_WIDE_INT len = int_size_in_bytes (type);
>    if (len == -1 || len > 4 * POINTER_SIZE / BITS_PER_UNIT)
>      return false;
> -  if (lang_hooks.decls.omp_privatize_by_reference (decl))
> +  if (omp_privatize_by_reference (decl))
>      return false;
>    return true;
>  }
> @@ -10698,7 +10699,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, 
> void *data)
>         OMP_CLAUSE_CHAIN (clause) = nc;
>       }
>        else if (gimplify_omp_ctxp->target_firstprivatize_array_bases
> -            && lang_hooks.decls.omp_privatize_by_reference (decl))
> +            && omp_privatize_by_reference (decl))
>       {
>         OMP_CLAUSE_DECL (clause) = build_simple_mem_ref (decl);
>         OMP_CLAUSE_SIZE (clause)
> diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
> index 66c64f5a37b..7ce0663ba70 100644
> --- a/gcc/omp-expand.c
> +++ b/gcc/omp-expand.c
> @@ -4232,9 +4232,8 @@ expand_omp_for_generic (struct omp_region *region,
>         && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
>       {
>         tree d = OMP_CLAUSE_DECL (c);
> -       bool is_ref = omp_is_reference (d);
>         tree t = d, a, dest;
> -       if (is_ref)
> +       if (omp_privatize_by_reference (t))
>           t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
>         tree type = TREE_TYPE (t);
>         if (POINTER_TYPE_P (type))
> @@ -5236,9 +5235,8 @@ expand_omp_for_static_nochunk (struct omp_region 
> *region,
>         && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
>       {
>         tree d = OMP_CLAUSE_DECL (c);
> -       bool is_ref = omp_is_reference (d);
>         tree t = d, a, dest;
> -       if (is_ref)
> +       if (omp_privatize_by_reference (t))
>           t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
>         if (itercnt == NULL_TREE)
>           {
> @@ -5952,9 +5950,8 @@ expand_omp_for_static_chunk (struct omp_region *region,
>         && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
>       {
>         tree d = OMP_CLAUSE_DECL (c);
> -       bool is_ref = omp_is_reference (d);
>         tree t = d, a, dest;
> -       if (is_ref)
> +       if (omp_privatize_by_reference (t))
>           t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
>         tree type = TREE_TYPE (t);
>         if (POINTER_TYPE_P (type))
> diff --git a/gcc/omp-general.c b/gcc/omp-general.c
> index b46a537e281..cc6aecb1d66 100644
> --- a/gcc/omp-general.c
> +++ b/gcc/omp-general.c
> @@ -79,10 +79,11 @@ omp_check_optional_argument (tree decl, bool 
> for_present_check)
>    return lang_hooks.decls.omp_check_optional_argument (decl, 
> for_present_check);
>  }
>  
> -/* Return true if DECL is a reference type.  */
> +/* True if OpenMP should privatize what this DECL points to rather
> +   than the DECL itself.  */
>  
>  bool
> -omp_is_reference (tree decl)
> +omp_privatize_by_reference (tree decl)
>  {
>    return lang_hooks.decls.omp_privatize_by_reference (decl);
>  }
> diff --git a/gcc/omp-general.h b/gcc/omp-general.h
> index 5c3e0f0e205..6a1468d2798 100644
> --- a/gcc/omp-general.h
> +++ b/gcc/omp-general.h
> @@ -93,7 +93,7 @@ struct omp_for_data
>  extern tree omp_find_clause (tree clauses, enum omp_clause_code kind);
>  extern bool omp_is_allocatable_or_ptr (tree decl);
>  extern tree omp_check_optional_argument (tree decl, bool for_present_check);
> -extern bool omp_is_reference (tree decl);
> +extern bool omp_privatize_by_reference (tree decl);
>  extern void omp_adjust_for_condition (location_t loc, enum tree_code 
> *cond_code,
>                                     tree *n2, tree v, tree step);
>  extern tree omp_get_for_step_from_incr (location_t loc, tree incr);
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index a0b41afa3eb..bbade6f1eb8 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -736,7 +736,7 @@ build_outer_var_ref (tree var, omp_context *ctx,
>      }
>    else if (outer)
>      x = lookup_decl (var, outer);
> -  else if (omp_is_reference (var))
> +  else if (omp_privatize_by_reference (var))
>      /* This can happen with orphaned constructs.  If var is reference, it is
>         possible it is shared and as such valid.  */
>      x = var;
> @@ -759,7 +759,7 @@ build_outer_var_ref (tree var, omp_context *ctx,
>       }
>      }
>  
> -  if (omp_is_reference (var))
> +  if (omp_privatize_by_reference (var))
>      x = build_simple_mem_ref (x);
>  
>    return x;
> @@ -824,7 +824,8 @@ install_var_field (tree var, bool by_ref, int mask, 
> omp_context *ctx)
>      }
>    else if (by_ref)
>      type = build_pointer_type (type);
> -  else if ((mask & (32 | 3)) == 1 && omp_is_reference (var))
> +  else if ((mask & (32 | 3)) == 1
> +        && omp_privatize_by_reference (var))
>      type = TREE_TYPE (type);
>  
>    field = build_decl (DECL_SOURCE_LOCATION (var),
> @@ -1217,7 +1218,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>         if ((! TREE_READONLY (decl) && !OMP_CLAUSE_SHARED_READONLY (c))
>             || TREE_ADDRESSABLE (decl)
>             || by_ref
> -           || omp_is_reference (decl))
> +           || omp_privatize_by_reference (decl))
>           {
>             by_ref = use_pointer_for_field (decl, ctx);
>             install_var_field (decl, by_ref, 3, ctx);
> @@ -1368,7 +1369,10 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>             && is_gimple_omp_offloaded (ctx->stmt))
>           {
>             if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
> -             install_var_field (decl, !omp_is_reference (decl), 3, ctx);
> +             {
> +               by_ref = !omp_privatize_by_reference (decl);
> +               install_var_field (decl, by_ref, 3, ctx);
> +             }
>             else if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
>               install_var_field (decl, true, 3, ctx);
>             else
> @@ -1396,7 +1400,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>             by_ref = use_pointer_for_field (decl, NULL);
>  
>             if (is_task_ctx (ctx)
> -               && (global || by_ref || omp_is_reference (decl)))
> +               && (global || by_ref || omp_privatize_by_reference (decl)))
>               {
>                 if (ctx->allocate_map
>                     && ctx->allocate_map->get (decl))
> @@ -1420,7 +1424,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>         if (lang_hooks.decls.omp_array_data (decl, true))
>           install_var_field (decl, false, 19, ctx);
>         else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
> -                 && !omp_is_reference (decl)
> +                 && !omp_privatize_by_reference (decl)
>                   && !omp_is_allocatable_or_ptr (decl))
>                  || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
>           install_var_field (decl, true, 11, ctx);
> @@ -4694,7 +4698,7 @@ lower_private_allocate (tree var, tree new_var, tree 
> &allocator,
>        allocator = *allocatorp;
>    if (allocator == NULL_TREE)
>      return false;
> -  if (!is_ref && omp_is_reference (var))
> +  if (!is_ref && omp_privatize_by_reference (var))
>      {
>        allocator = NULL_TREE;
>        return false;
> @@ -4792,7 +4796,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>       case OMP_CLAUSE_LASTPRIVATE:
>         if (is_variable_sized (OMP_CLAUSE_DECL (c)))
>           sctx.max_vf = 1;
> -       else if (omp_is_reference (OMP_CLAUSE_DECL (c)))
> +       else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c)))
>           {
>             tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c)));
>             if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype)))
> @@ -4804,7 +4808,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>         if (TREE_CODE (OMP_CLAUSE_DECL (c)) == MEM_REF
>             || is_variable_sized (OMP_CLAUSE_DECL (c)))
>           sctx.max_vf = 1;
> -       else if (omp_is_reference (OMP_CLAUSE_DECL (c)))
> +       else if (omp_privatize_by_reference (OMP_CLAUSE_DECL (c)))
>           {
>             tree rtype = TREE_TYPE (TREE_TYPE (OMP_CLAUSE_DECL (c)));
>             if (!TREE_CONSTANT (TYPE_SIZE_UNIT (rtype)))
> @@ -4966,7 +4970,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                        original address, it is always the address of the
>                        global variable itself.  */
>                     if (!DECL_P (var)
> -                       || omp_is_reference (var)
> +                       || omp_privatize_by_reference (var)
>                         || !is_global_var
>                               (maybe_lookup_decl_in_outer_ctx (var, ctx)))
>                       {
> @@ -5407,10 +5411,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                     tree ref = build_outer_var_ref (var, ctx);
>                     /* For ref build_outer_var_ref already performs this.  */
>                     if (TREE_CODE (d) == INDIRECT_REF)
> -                     gcc_assert (omp_is_reference (var));
> +                     gcc_assert (omp_privatize_by_reference (var));
>                     else if (TREE_CODE (d) == ADDR_EXPR)
>                       ref = build_fold_addr_expr (ref);
> -                   else if (omp_is_reference (var))
> +                   else if (omp_privatize_by_reference (var))
>                       ref = build_fold_addr_expr (ref);
>                     ref = fold_convert_loc (clause_loc, ptype, ref);
>                     if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)
> @@ -5557,7 +5561,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                 bool by_ref = use_pointer_for_field (var, ctx);
>                 x = build_receiver_ref (var, by_ref, ctx);
>               }
> -           if (!omp_is_reference (var))
> +           if (!omp_privatize_by_reference (var))
>               x = build_fold_addr_expr (x);
>             x = fold_convert (ptr_type_node, x);
>             unsigned cnt = task_reduction_cnt - 1;
> @@ -5573,7 +5577,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>         else if (pass == 3)
>           {
>             tree type = TREE_TYPE (new_var);
> -           if (!omp_is_reference (var))
> +           if (!omp_privatize_by_reference (var))
>               type = build_pointer_type (type);
>             if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION)
>               {
> @@ -5601,7 +5605,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>               }
>             x = fold_convert (type, x);
>             tree t;
> -           if (omp_is_reference (var))
> +           if (omp_privatize_by_reference (var))
>               {
>                 gimplify_assign (new_var, x, ilist);
>                 t = new_var;
> @@ -5662,7 +5666,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                 gimplify_assign (ptr, x, ilist);
>               }
>           }
> -       else if (omp_is_reference (var)
> +       else if (omp_privatize_by_reference (var)
>                  && (c_kind != OMP_CLAUSE_FIRSTPRIVATE
>                      || !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c)))
>           {
> @@ -5827,11 +5831,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                              || (gimple_omp_for_index (ctx->stmt, 0)
>                                  != new_var)))
>                      || OMP_CLAUSE_CODE (c) == OMP_CLAUSE__CONDTEMP_
> -                    || omp_is_reference (var))
> +                    || omp_privatize_by_reference (var))
>                     && lower_rec_simd_input_clauses (new_var, ctx, &sctx,
>                                                      ivar, lvar))
>                   {
> -                   if (omp_is_reference (var))
> +                   if (omp_privatize_by_reference (var))
>                       {
>                         gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                         tree new_vard = TREE_OPERAND (new_var, 0);
> @@ -5917,7 +5921,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                       }
>                     break;
>                   }
> -               if (omp_is_reference (var))
> +               if (omp_privatize_by_reference (var))
>                   {
>                     gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                     tree new_vard = TREE_OPERAND (new_var, 0);
> @@ -5987,7 +5991,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>           case OMP_CLAUSE_FIRSTPRIVATE:
>             if (is_task_ctx (ctx))
>               {
> -               if ((omp_is_reference (var)
> +               if ((omp_privatize_by_reference (var)
>                      && !OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c))
>                     || is_variable_sized (var))
>                   goto do_dtor;
> @@ -6014,7 +6018,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                   }
>               }
>             if (OMP_CLAUSE_FIRSTPRIVATE_NO_REFERENCE (c)
> -               && omp_is_reference (var))
> +               && omp_privatize_by_reference (var))
>               {
>                 x = build_outer_var_ref (var, ctx);
>                 gcc_assert (TREE_CODE (x) == MEM_REF
> @@ -6059,7 +6063,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>  
>                     if (OMP_CLAUSE_LINEAR_ARRAY (c))
>                       {
> -                       if (omp_is_reference (var))
> +                       if (omp_privatize_by_reference (var))
>                           {
>                             gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                             tree new_vard = TREE_OPERAND (new_var, 0);
> @@ -6096,11 +6100,11 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>  
>                 if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR
>                      || TREE_ADDRESSABLE (new_var)
> -                    || omp_is_reference (var))
> +                    || omp_privatize_by_reference (var))
>                     && lower_rec_simd_input_clauses (new_var, ctx, &sctx,
>                                                      ivar, lvar))
>                   {
> -                   if (omp_is_reference (var))
> +                   if (omp_privatize_by_reference (var))
>                       {
>                         gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                         tree new_vard = TREE_OPERAND (new_var, 0);
> @@ -6137,7 +6141,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                       gimplify_and_add (x, &llist[1]);
>                     break;
>                   }
> -               if (omp_is_reference (var))
> +               if (omp_privatize_by_reference (var))
>                   {
>                     gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                     tree new_vard = TREE_OPERAND (new_var, 0);
> @@ -6220,14 +6224,14 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                                             NULL_TREE);
>                     x = build_outer_var_ref (var, ctx);
>  
> -                   if (omp_is_reference (var)
> +                   if (omp_privatize_by_reference (var)
>                         && !useless_type_conversion_p (ptype, TREE_TYPE (x)))
>                       x = build_fold_addr_expr_loc (clause_loc, x);
>                   }
>                 SET_DECL_VALUE_EXPR (placeholder, x);
>                 DECL_HAS_VALUE_EXPR_P (placeholder) = 1;
>                 tree new_vard = new_var;
> -               if (omp_is_reference (var))
> +               if (omp_privatize_by_reference (var))
>                   {
>                     gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                     new_vard = TREE_OPERAND (new_var, 0);
> @@ -6387,7 +6391,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                    for it because it is undesirable if SIMD arrays are used.
>                    But if they aren't used, we need to emit the deferred
>                    initialization now.  */
> -               else if (omp_is_reference (var) && is_simd)
> +               else if (omp_privatize_by_reference (var) && is_simd)
>                   handle_simd_reference (clause_loc, new_vard, ilist);
>  
>                 tree lab2 = NULL_TREE;
> @@ -6582,7 +6586,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                 bool is_truth_op
>                   = (code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR);
>                 tree new_vard = new_var;
> -               if (is_simd && omp_is_reference (var))
> +               if (is_simd && omp_privatize_by_reference (var))
>                   {
>                     gcc_assert (TREE_CODE (new_var) == MEM_REF);
>                     new_vard = TREE_OPERAND (new_var, 0);
> @@ -6653,7 +6657,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
> *ilist, gimple_seq *dlist,
>                     lower_private_allocate (var, new_var, allocator,
>                                             allocate_ptr, ilist, ctx,
>                                             false, NULL_TREE);
> -                   if (omp_is_reference (var) && is_simd)
> +                   if (omp_privatize_by_reference (var) && is_simd)
>                       handle_simd_reference (clause_loc, new_vard, ilist);
>                     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
>                         && OMP_CLAUSE_REDUCTION_INSCAN (c))
> @@ -7254,7 +7258,7 @@ lower_lastprivate_clauses (tree clauses, tree 
> predicate, gimple_seq *body_p,
>           }
>         if (!x)
>           x = build_outer_var_ref (var, ctx, OMP_CLAUSE_LASTPRIVATE);
> -       if (omp_is_reference (var))
> +       if (omp_privatize_by_reference (var))
>           new_var = build_simple_mem_ref_loc (clause_loc, new_var);
>         x = lang_hooks.decls.omp_clause_assign_op (c, x, new_var);
>         gimplify_and_add (x, this_stmt_list);
> @@ -7400,7 +7404,7 @@ lower_oacc_reductions (location_t loc, tree clauses, 
> tree level, bool inner,
>               && maybe_lookup_field (orig, outer) && !is_private)
>             {
>               ref_to_res = build_receiver_ref (orig, false, outer);
> -             if (omp_is_reference (orig))
> +             if (omp_privatize_by_reference (orig))
>                 ref_to_res = build_simple_mem_ref (ref_to_res);
>  
>               tree type = TREE_TYPE (var);
> @@ -7430,7 +7434,7 @@ lower_oacc_reductions (location_t loc, tree clauses, 
> tree level, bool inner,
>       if (!ref_to_res)
>         ref_to_res = integer_zero_node;
>  
> -     if (omp_is_reference (orig))
> +     if (omp_privatize_by_reference (orig))
>         {
>           tree type = TREE_TYPE (var);
>           const char *id = IDENTIFIER_POINTER (DECL_NAME (var));
> @@ -7610,7 +7614,8 @@ lower_reduction_clauses (tree clauses, gimple_seq 
> *stmt_seqp,
>           }
>       }
>        new_var = lookup_decl (var, ctx);
> -      if (var == OMP_CLAUSE_DECL (c) && omp_is_reference (var))
> +      if (var == OMP_CLAUSE_DECL (c)
> +       && omp_privatize_by_reference (var))
>       new_var = build_simple_mem_ref_loc (clause_loc, new_var);
>        ref = build_outer_var_ref (var, ctx, ccode);
>        code = OMP_CLAUSE_REDUCTION_CODE (c);
> @@ -7679,7 +7684,8 @@ lower_reduction_clauses (tree clauses, gimple_seq 
> *stmt_seqp,
>         if (TREE_CODE (d) == INDIRECT_REF)
>           {
>             new_var = build_simple_mem_ref_loc (clause_loc, new_var);
> -           gcc_assert (omp_is_reference (var) && var == orig_var);
> +           gcc_assert (omp_privatize_by_reference (var)
> +                       && var == orig_var);
>           }
>         else if (TREE_CODE (d) == ADDR_EXPR)
>           {
> @@ -7692,7 +7698,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
> *stmt_seqp,
>         else
>           {
>             gcc_assert (orig_var == var);
> -           if (omp_is_reference (var))
> +           if (omp_privatize_by_reference (var))
>               ref = build_fold_addr_expr (ref);
>           }
>         if (DECL_P (v))
> @@ -7778,7 +7784,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
> *stmt_seqp,
>       {
>         tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
>  
> -       if (omp_is_reference (var)
> +       if (omp_privatize_by_reference (var)
>             && !useless_type_conversion_p (TREE_TYPE (placeholder),
>                                            TREE_TYPE (ref)))
>           ref = build_fold_addr_expr_loc (clause_loc, ref);
> @@ -7864,7 +7870,7 @@ lower_copyprivate_clauses (tree clauses, gimple_seq 
> *slist, gimple_seq *rlist,
>                                 ref);
>         ref = build_fold_indirect_ref_loc (clause_loc, ref);
>       }
> -      if (omp_is_reference (var))
> +      if (omp_privatize_by_reference (var))
>       {
>         ref = fold_convert_loc (clause_loc, TREE_TYPE (new_var), ref);
>         ref = build_simple_mem_ref_loc (clause_loc, ref);
> @@ -8017,7 +8023,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, 
> gimple_seq *olist,
>         break;
>  
>       case OMP_CLAUSE_LASTPRIVATE:
> -       if (by_ref || omp_is_reference (val))
> +       if (by_ref || omp_privatize_by_reference (val))
>           {
>             if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c))
>               continue;
> @@ -8039,7 +8045,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, 
> gimple_seq *olist,
>             if (is_task_ctx (ctx))
>               by_ref = use_pointer_for_field (val, ctx);
>             else
> -             do_out = !(by_ref || omp_is_reference (val));
> +             do_out = !(by_ref || omp_privatize_by_reference (val));
>           }
>         else
>           by_ref = TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE;
> @@ -8913,7 +8919,7 @@ omp_task_reduction_iterate (int pass, enum tree_code 
> code,
>       }
>        else
>       {
> -       if (omp_is_reference (*decl))
> +       if (omp_privatize_by_reference (*decl))
>           *type = TREE_TYPE (*type);
>         if (pass != (!TREE_CONSTANT (TYPE_SIZE_UNIT (*type))))
>           continue;
> @@ -9201,7 +9207,7 @@ lower_omp_task_reductions (omp_context *ctx, enum 
> tree_code code, tree clauses,
>         else
>           {
>             t = ref = maybe_lookup_decl_in_outer_ctx (var, ctx);
> -           if (!omp_is_reference (decl))
> +           if (!omp_privatize_by_reference (decl))
>               t = build_fold_addr_expr (t);
>           }
>         t = fold_convert (pointer_sized_int_node, t);
> @@ -9284,7 +9290,8 @@ lower_omp_task_reductions (omp_context *ctx, enum 
> tree_code code, tree clauses,
>                             build_simple_mem_ref (ptr), field, NULL_TREE);
>  
>         enum tree_code rcode = OMP_CLAUSE_REDUCTION_CODE (c);
> -       if (TREE_CODE (decl) != MEM_REF && omp_is_reference (decl))
> +       if (TREE_CODE (decl) != MEM_REF
> +           && omp_privatize_by_reference (decl))
>           ref = build_simple_mem_ref (ref);
>         /* reduction(-:var) sums up the partial results, so it acts
>            identically to reduction(+:var).  */
> @@ -9400,7 +9407,7 @@ lower_omp_task_reductions (omp_context *ctx, enum 
> tree_code code, tree clauses,
>                 gimple_seq_add_stmt (end, g);
>                 gimple_seq_add_stmt (end, gimple_build_label (lab5));
>               }
> -           if (omp_is_reference (decl)
> +           if (omp_privatize_by_reference (decl)
>                 && !useless_type_conversion_p (TREE_TYPE (placeholder),
>                                                TREE_TYPE (ref)))
>               ref = build_fold_addr_expr_loc (OMP_CLAUSE_LOCATION (c), ref);
> @@ -9414,7 +9421,7 @@ lower_omp_task_reductions (omp_context *ctx, enum 
> tree_code code, tree clauses,
>             gcc_assert (d);
>             if (DECL_HAS_VALUE_EXPR_P (d))
>               oldv = DECL_VALUE_EXPR (d);
> -           if (omp_is_reference (var))
> +           if (omp_privatize_by_reference (var))
>               {
>                 tree v = fold_convert (TREE_TYPE (d),
>                                        build_fold_addr_expr (new_var));
> @@ -9986,7 +9993,7 @@ lower_omp_scan (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           tree var4 = NULL_TREE;
>           tree lane0 = NULL_TREE;
>           tree new_vard = new_var;
> -         if (omp_is_reference (var))
> +         if (omp_privatize_by_reference (var))
>             {
>               new_var = build_simple_mem_ref_loc (clause_loc, new_var);
>               val = new_var;
> @@ -10853,7 +10860,7 @@ lower_omp_for_scan (gimple_seq *body_p, gimple_seq 
> *dlist, gomp_for *stmt,
>       tree new_var = lookup_decl (var, ctx);
>       tree var3 = NULL_TREE;
>       tree new_vard = new_var;
> -     if (omp_is_reference (var))
> +     if (omp_privatize_by_reference (var))
>         new_var = build_simple_mem_ref_loc (clause_loc, new_var);
>       if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
>         {
> @@ -12026,7 +12033,8 @@ create_task_copyfn (gomp_task *task_stmt, omp_context 
> *ctx)
>             sf = *tcctx.cb.decl_map->get (sf);
>           src = build_simple_mem_ref_loc (loc, sarg);
>           src = omp_build_component_ref (src, sf);
> -         if (use_pointer_for_field (decl, NULL) || omp_is_reference (decl))
> +         if (use_pointer_for_field (decl, NULL)
> +             || omp_privatize_by_reference (decl))
>             src = build_simple_mem_ref_loc (loc, src);
>         }
>       else
> @@ -12646,7 +12654,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
>             {
>               gcc_assert (is_gimple_omp_oacc (ctx->stmt));
> -             if (omp_is_reference (new_var)
> +             if (omp_privatize_by_reference (new_var)
>                   && (TREE_CODE (TREE_TYPE (new_var)) != POINTER_TYPE
>                       || DECL_BY_REFERENCE (var)))
>                 {
> @@ -12684,7 +12692,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>         }
>       map_cnt++;
>       var = OMP_CLAUSE_DECL (c);
> -     if (!omp_is_reference (var)
> +     if (!omp_privatize_by_reference (var)
>           && !is_gimple_reg_type (TREE_TYPE (var)))
>         {
>           tree new_var = lookup_decl (var, ctx);
> @@ -12751,7 +12759,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           DECL_HAS_VALUE_EXPR_P (new_var) = 1;
>         }
>       else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
> -               && !omp_is_reference (var)
> +               && !omp_privatize_by_reference (var)
>                 && !omp_is_allocatable_or_ptr (var)
>                 && !lang_hooks.decls.omp_array_data (var, true))
>                || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE)
> @@ -12974,7 +12982,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_FIRSTPRIVATE)
>                 {
>                   gcc_assert (is_gimple_omp_oacc (ctx->stmt));
> -                 if (!omp_is_reference (var))
> +                 if (!omp_privatize_by_reference (var))
>                     {
>                       if (is_gimple_reg (var)
>                           && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
> @@ -13137,7 +13145,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           if (is_gimple_omp_oacc (ctx->stmt))
>             goto oacc_firstprivate_map;
>           ovar = OMP_CLAUSE_DECL (c);
> -         if (omp_is_reference (ovar))
> +         if (omp_privatize_by_reference (ovar))
>             talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar)));
>           else
>             talign = DECL_ALIGN_UNIT (ovar);
> @@ -13145,7 +13153,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           x = build_sender_ref (ovar, ctx);
>           tkind = GOMP_MAP_FIRSTPRIVATE;
>           type = TREE_TYPE (ovar);
> -         if (omp_is_reference (ovar))
> +         if (omp_privatize_by_reference (ovar))
>             type = TREE_TYPE (type);
>           if ((INTEGRAL_TYPE_P (type)
>                && TYPE_PRECISION (type) <= POINTER_SIZE)
> @@ -13153,7 +13161,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>             {
>               tkind = GOMP_MAP_FIRSTPRIVATE_INT;
>               tree t = var;
> -             if (omp_is_reference (var))
> +             if (omp_privatize_by_reference (var))
>                 t = build_simple_mem_ref (var);
>               else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
>                 suppress_warning (var);
> @@ -13162,7 +13170,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>               t = fold_convert (TREE_TYPE (x), t);
>               gimplify_assign (x, t, &ilist);
>             }
> -         else if (omp_is_reference (var))
> +         else if (omp_privatize_by_reference (var))
>             gimplify_assign (x, var, &ilist);
>           else if (is_gimple_reg (var))
>             {
> @@ -13181,7 +13189,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>             }
>           if (tkind == GOMP_MAP_FIRSTPRIVATE_INT)
>             s = size_int (0);
> -         else if (omp_is_reference (ovar))
> +         else if (omp_privatize_by_reference (ovar))
>             s = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ovar)));
>           else
>             s = TYPE_SIZE_UNIT (TREE_TYPE (ovar));
> @@ -13236,13 +13244,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           if (lang_hooks.decls.omp_array_data (ovar, true))
>             var = lang_hooks.decls.omp_array_data (ovar, false);
>           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
> -                   && !omp_is_reference (ovar)
> +                   && !omp_privatize_by_reference (ovar)
>                     && !omp_is_allocatable_or_ptr (ovar))
>                    || TREE_CODE (type) == ARRAY_TYPE)
>             var = build_fold_addr_expr (var);
>           else
>             {
> -             if (omp_is_reference (ovar)
> +             if (omp_privatize_by_reference (ovar)
>                   || omp_check_optional_argument (ovar, false)
>                   || omp_is_allocatable_or_ptr (ovar))
>                 {
> @@ -13251,7 +13259,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>                       && TREE_CODE (type) != ARRAY_TYPE
>                       && ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR
>                           && !omp_is_allocatable_or_ptr (ovar))
> -                        || (omp_is_reference (ovar)
> +                        || (omp_privatize_by_reference (ovar)
>                              && omp_is_allocatable_or_ptr (ovar))))
>                     var = build_simple_mem_ref (var);
>                   var = fold_convert (TREE_TYPE (x), var);
> @@ -13366,13 +13374,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           if (is_gimple_omp_oacc (ctx->stmt))
>             break;
>           var = OMP_CLAUSE_DECL (c);
> -         if (omp_is_reference (var)
> +         if (omp_privatize_by_reference (var)
>               || is_gimple_reg_type (TREE_TYPE (var)))
>             {
>               tree new_var = lookup_decl (var, ctx);
>               tree type;
>               type = TREE_TYPE (var);
> -             if (omp_is_reference (var))
> +             if (omp_privatize_by_reference (var))
>                 type = TREE_TYPE (type);
>               if ((INTEGRAL_TYPE_P (type)
>                    && TYPE_PRECISION (type) <= POINTER_SIZE)
> @@ -13384,7 +13392,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>                   x = fold_convert (type, x);
>                   gimplify_expr (&x, &new_body, NULL, is_gimple_val,
>                                  fb_rvalue);
> -                 if (omp_is_reference (var))
> +                 if (omp_privatize_by_reference (var))
>                     {
>                       tree v = create_tmp_var_raw (type, get_name (var));
>                       gimple_add_tmp_var (v);
> @@ -13398,7 +13406,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>                 }
>               else
>                 {
> -                 x = build_receiver_ref (var, !omp_is_reference (var), ctx);
> +                 bool by_ref = !omp_privatize_by_reference (var);
> +                 x = build_receiver_ref (var, by_ref, ctx);
>                   gimplify_expr (&x, &new_body, NULL, is_gimple_val,
>                                  fb_rvalue);
>                   gimple_seq_add_stmt (&new_body,
> @@ -13422,7 +13431,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>           if (is_gimple_omp_oacc (ctx->stmt))
>             break;
>           var = OMP_CLAUSE_DECL (c);
> -         if (omp_is_reference (var))
> +         if (omp_privatize_by_reference (var))
>             {
>               location_t clause_loc = OMP_CLAUSE_LOCATION (c);
>               tree new_var = lookup_decl (var, ctx);
> @@ -13465,7 +13474,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>  
>           if (is_array_data)
>             {
> -             bool is_ref = omp_is_reference (var);
> +             bool is_ref = omp_privatize_by_reference (var);
>               do_optional_check = true;
>               /* First, we copy the descriptor data from the host; then
>                  we update its data to point to the target address.  */
> @@ -13509,7 +13518,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>                                    gimple_build_assign (new_var, x));
>             }
>           else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR
> -                   && !omp_is_reference (var)
> +                   && !omp_privatize_by_reference (var)
>                     && !omp_is_allocatable_or_ptr (var))
>                    || TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE)
>             {
> @@ -13526,13 +13535,13 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>             {
>               tree type = TREE_TYPE (var);
>               new_var = lookup_decl (var, ctx);
> -             if (omp_is_reference (var))
> +             if (omp_privatize_by_reference (var))
>                 {
>                   type = TREE_TYPE (type);
>                   if (POINTER_TYPE_P (type)
>                       && TREE_CODE (type) != ARRAY_TYPE
>                       && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_USE_DEVICE_ADDR
> -                         || (omp_is_reference (var)
> +                         || (omp_privatize_by_reference (var)
>                               && omp_is_allocatable_or_ptr (var))))
>                     {
>                       tree v = create_tmp_var_raw (type, get_name (var));
> @@ -13650,7 +13659,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>                                                    offset));
>                 }
>               else
> -               is_ref = omp_is_reference (var);
> +               is_ref = omp_privatize_by_reference (var);
>               if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_REFERENCE)
>                 is_ref = false;
>               bool ref_to_array = false;
> @@ -13730,7 +13739,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
> omp_context *ctx)
>               gimple_seq_add_stmt (&new_body,
>                                    gimple_build_assign (new_pvar, x));
>             }
> -         else if (omp_is_reference (var) && !is_gimple_omp_oacc (ctx->stmt))
> +         else if (omp_privatize_by_reference (var)
> +                  && !is_gimple_omp_oacc (ctx->stmt))
>             {
>               location_t clause_loc = OMP_CLAUSE_LOCATION (c);
>               tree new_var = lookup_decl (var, ctx);
> -- 
> 2.25.1
> 


        Jakub

Reply via email to