Hi!

On Wed, 13 Apr 2016 20:20:19 +0200, Bernd Schmidt <bschm...@redhat.com> wrote:
> On 04/13/2016 07:56 PM, Thomas Schwinge wrote:
> > 0001-Split-up-gcc-omp-low.c-plain.patch.xz attached.
> 
> That looks much better. However, the //OMPWHATEVER comments are not 
> really all that helpful.

They're helpful in the word-diff patch, as they show where I moved stuff.
I agree that they can't serve this purpose in the line-diff patch.

> I think the next step would be to clear out all 
> this stuff including the OMPCUT markers

I think the first step would be to get agreement on the several questions
that I posted yesterday.  That is, which stuff to move, into which files,
how to structure it all, and so on.  That's what I hoped the word-diff
patch would help with.  Everything else sounds a bit like busywork to me;
that is:

> start with an 
> initial patch that includes everything that actually modifies code 
> rather than moving it (omp_is_reference seems to be the major thing here).

I don't know how meaningful it is to create/discuss/review/commit the
following patch until the overall approach has been agreed upon?

commit 8ac6b83350022c74bb2af8006e51f3620889e7c1
Author: Thomas Schwinge <tho...@codesourcery.com>
Date:   Thu Apr 14 15:25:24 2016 +0200

    gcc/omp-low.c:is_reference -> gcc/omp-low.h:omp_is_reference
    
        gcc/
        * omp-low.h: Include "langhooks.h".  Define omp_is_reference here,
        and...
        * omp-low.c: ... don't define is_reference here.  Adjust all
        users.
---
 gcc/omp-low.c | 102 +++++++++++++++++++++++++++-------------------------------
 gcc/omp-low.h |  10 ++++++
 2 files changed, 57 insertions(+), 55 deletions(-)

diff --git gcc/omp-low.c gcc/omp-low.c
index 7335abc..bb9c61e 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -1039,21 +1039,13 @@ is_variable_sized (const_tree expr)
   return !TREE_CONSTANT (TYPE_SIZE_UNIT (TREE_TYPE (expr)));
 }
 
-/* Return true if DECL is a reference type.  */
-
-static inline bool
-is_reference (tree decl)
-{
-  return lang_hooks.decls.omp_privatize_by_reference (decl);
-}
-
 /* Return the type of a decl.  If the decl is reference type,
    return its base type.  */
 static inline tree
 get_base_type (tree decl)
 {
   tree type = TREE_TYPE (decl);
-  if (is_reference (decl))
+  if (omp_is_reference (decl))
     type = TREE_TYPE (type);
   return type;
 }
@@ -1348,7 +1340,7 @@ build_outer_var_ref (tree var, omp_context *ctx, bool 
lastprivate = false)
        }
        x = lookup_decl (var, outer);
     }
-  else if (is_reference (var))
+  else if (omp_is_reference (var))
     /* This can happen with orphaned constructs.  If var is reference, it is
        possible it is shared and as such valid.  */
     x = var;
@@ -1371,7 +1363,7 @@ build_outer_var_ref (tree var, omp_context *ctx, bool 
lastprivate = false)
        }
     }
 
-  if (is_reference (var))
+  if (omp_is_reference (var))
     x = build_simple_mem_ref (x);
 
   return x;
@@ -1433,7 +1425,7 @@ install_var_field (tree var, bool by_ref, int mask, 
omp_context *ctx,
       if (base_pointers_restrict)
        type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
     }
-  else if ((mask & 3) == 1 && is_reference (var))
+  else if ((mask & 3) == 1 && omp_is_reference (var))
     type = TREE_TYPE (type);
 
   field = build_decl (DECL_SOURCE_LOCATION (var),
@@ -1904,7 +1896,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx,
          if ((! TREE_READONLY (decl) && !OMP_CLAUSE_SHARED_READONLY (c))
              || TREE_ADDRESSABLE (decl)
              || by_ref
-             || is_reference (decl))
+             || omp_is_reference (decl))
            {
              by_ref = use_pointer_for_field (decl, ctx);
              install_var_field (decl, by_ref, 3, ctx);
@@ -1954,7 +1946,7 @@ 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, !is_reference (decl), 3, ctx);
+               install_var_field (decl, !omp_is_reference (decl), 3, ctx);
              else if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
                install_var_field (decl, true, 3, ctx);
              else
@@ -1973,7 +1965,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 || is_reference (decl)))
+                 && (global || by_ref || omp_is_reference (decl)))
                {
                  install_var_field (decl, false, 1, ctx);
                  if (!global)
@@ -4673,10 +4665,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 (is_reference (var));
+                   gcc_assert (omp_is_reference (var));
                  else if (TREE_CODE (d) == ADDR_EXPR)
                    ref = build_fold_addr_expr (ref);
-                 else if (is_reference (var))
+                 else if (omp_is_reference (var))
                    ref = build_fold_addr_expr (ref);
                  ref = fold_convert_loc (clause_loc, ptype, ref);
                  if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)
@@ -4840,7 +4832,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *dlist,
                  gimplify_assign (ptr, x, ilist);
                }
            }
-         else if (is_reference (var))
+         else if (omp_is_reference (var))
            {
              /* For references that are being privatized for Fortran,
                 allocate new backing storage for the new pointer
@@ -5007,7 +4999,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *dlist,
            case OMP_CLAUSE_FIRSTPRIVATE:
              if (is_task_ctx (ctx))
                {
-                 if (is_reference (var) || is_variable_sized (var))
+                 if (omp_is_reference (var) || is_variable_sized (var))
                    goto do_dtor;
                  else if (is_global_var (maybe_lookup_decl_in_outer_ctx (var,
                                                                          ctx))
@@ -5135,14 +5127,14 @@ lower_rec_input_clauses (tree clauses, gimple_seq 
*ilist, gimple_seq *dlist,
                  gimple *tseq;
                  x = build_outer_var_ref (var, ctx);
 
-                 if (is_reference (var)
+                 if (omp_is_reference (var)
                      && !useless_type_conversion_p (TREE_TYPE (placeholder),
                                                     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 (is_reference (var))
+                 if (omp_is_reference (var))
                    {
                      gcc_assert (TREE_CODE (new_var) == MEM_REF);
                      new_vard = TREE_OPERAND (new_var, 0);
@@ -5200,7 +5192,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 (is_reference (var) && is_simd)
+                 else if (omp_is_reference (var) && is_simd)
                    handle_simd_reference (clause_loc, new_vard, ilist);
                  x = lang_hooks.decls.omp_clause_default_ctor
                                (c, unshare_expr (new_var),
@@ -5236,7 +5228,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *dlist,
                    code = PLUS_EXPR;
 
                  tree new_vard = new_var;
-                 if (is_simd && is_reference (var))
+                 if (is_simd && omp_is_reference (var))
                    {
                      gcc_assert (TREE_CODE (new_var) == MEM_REF);
                      new_vard = TREE_OPERAND (new_var, 0);
@@ -5263,7 +5255,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *dlist,
                    }
                  else
                    {
-                     if (is_reference (var) && is_simd)
+                     if (omp_is_reference (var) && is_simd)
                        handle_simd_reference (clause_loc, new_vard, ilist);
                      gimplify_assign (new_var, x, ilist);
                      if (is_simd)
@@ -5514,7 +5506,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, 
gimple_seq *stmt_list,
            }
          if (!x)
            x = build_outer_var_ref (var, ctx, true);
-         if (is_reference (var))
+         if (omp_is_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, stmt_list);
@@ -5645,7 +5637,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 (is_reference (orig))
+               if (omp_is_reference (orig))
                  ref_to_res = build_simple_mem_ref (ref_to_res);
 
                tree type = TREE_TYPE (var);
@@ -5666,7 +5658,7 @@ lower_oacc_reductions (location_t loc, tree clauses, tree 
level, bool inner,
        if (!ref_to_res)
          ref_to_res = integer_zero_node;
 
-        if (is_reference (orig))
+        if (omp_is_reference (orig))
          {
            tree type = TREE_TYPE (var);
            const char *id = IDENTIFIER_POINTER (DECL_NAME (var));
@@ -5821,7 +5813,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
*stmt_seqp, omp_context *ctx)
            }
        }
       new_var = lookup_decl (var, ctx);
-      if (var == OMP_CLAUSE_DECL (c) && is_reference (var))
+      if (var == OMP_CLAUSE_DECL (c) && omp_is_reference (var))
        new_var = build_simple_mem_ref_loc (clause_loc, new_var);
       ref = build_outer_var_ref (var, ctx);
       code = OMP_CLAUSE_REDUCTION_CODE (c);
@@ -5875,7 +5867,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
*stmt_seqp, omp_context *ctx)
          if (TREE_CODE (d) == INDIRECT_REF)
            {
              new_var = build_simple_mem_ref_loc (clause_loc, new_var);
-             gcc_assert (is_reference (var) && var == orig_var);
+             gcc_assert (omp_is_reference (var) && var == orig_var);
            }
          else if (TREE_CODE (d) == ADDR_EXPR)
            {
@@ -5888,7 +5880,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
*stmt_seqp, omp_context *ctx)
          else
            {
              gcc_assert (orig_var == var);
-             if (is_reference (var))
+             if (omp_is_reference (var))
                ref = build_fold_addr_expr (ref);
            }
          if (DECL_P (v))
@@ -5962,7 +5954,7 @@ lower_reduction_clauses (tree clauses, gimple_seq 
*stmt_seqp, omp_context *ctx)
        {
          tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c);
 
-         if (is_reference (var)
+         if (omp_is_reference (var)
              && !useless_type_conversion_p (TREE_TYPE (placeholder),
                                             TREE_TYPE (ref)))
            ref = build_fold_addr_expr_loc (clause_loc, ref);
@@ -6030,7 +6022,7 @@ lower_copyprivate_clauses (tree clauses, gimple_seq 
*slist, gimple_seq *rlist,
                                  ref);
          ref = build_fold_indirect_ref_loc (clause_loc, ref);
        }
-      if (is_reference (var))
+      if (omp_is_reference (var))
        {
          ref = fold_convert_loc (clause_loc, TREE_TYPE (new_var), ref);
          ref = build_simple_mem_ref_loc (clause_loc, ref);
@@ -6169,7 +6161,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *olist,
          break;
 
        case OMP_CLAUSE_LASTPRIVATE:
-         if (by_ref || is_reference (val))
+         if (by_ref || omp_is_reference (val))
            {
              if (OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c))
                continue;
@@ -6186,7 +6178,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, 
gimple_seq *olist,
        case OMP_CLAUSE_REDUCTION:
          do_in = true;
          if (val == OMP_CLAUSE_DECL (c))
-           do_out = !(by_ref || is_reference (val));
+           do_out = !(by_ref || omp_is_reference (val));
          else
            by_ref = TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE;
          break;
@@ -8829,7 +8821,7 @@ expand_omp_for_generic (struct omp_region *region,
          && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
        {
          tree d = OMP_CLAUSE_DECL (c);
-         bool is_ref = is_reference (d);
+         bool is_ref = omp_is_reference (d);
          tree t = d, a, dest;
          if (is_ref)
            t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
@@ -9478,7 +9470,7 @@ expand_omp_for_static_nochunk (struct omp_region *region,
          && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
        {
          tree d = OMP_CLAUSE_DECL (c);
-         bool is_ref = is_reference (d);
+         bool is_ref = omp_is_reference (d);
          tree t = d, a, dest;
          if (is_ref)
            t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
@@ -9977,7 +9969,7 @@ expand_omp_for_static_chunk (struct omp_region *region,
          && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
        {
          tree d = OMP_CLAUSE_DECL (c);
-         bool is_ref = is_reference (d);
+         bool is_ref = omp_is_reference (d);
          tree t = d, a, dest;
          if (is_ref)
            t = build_simple_mem_ref_loc (OMP_CLAUSE_LOCATION (c), t);
@@ -15419,7 +15411,7 @@ 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) || is_reference (decl))
+           if (use_pointer_for_field (decl, NULL) || omp_is_reference (decl))
              src = build_simple_mem_ref_loc (loc, src);
          }
        else
@@ -15888,7 +15880,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 (is_reference (new_var))
+               if (omp_is_reference (new_var))
                  {
                    /* Create a local object to hold the instance
                       value.  */
@@ -15916,7 +15908,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
          goto oacc_firstprivate;
        map_cnt++;
        var = OMP_CLAUSE_DECL (c);
-       if (!is_reference (var)
+       if (!omp_is_reference (var)
            && !is_gimple_reg_type (TREE_TYPE (var)))
          {
            tree new_var = lookup_decl (var, ctx);
@@ -16122,7 +16114,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 (!is_reference (var))
+                   if (!omp_is_reference (var))
                      {
                        if (is_gimple_reg (var)
                            && OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
@@ -16268,7 +16260,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
            if (is_oacc_parallel (ctx))
              goto oacc_firstprivate_map;
            ovar = OMP_CLAUSE_DECL (c);
-           if (is_reference (ovar))
+           if (omp_is_reference (ovar))
              talign = TYPE_ALIGN_UNIT (TREE_TYPE (TREE_TYPE (ovar)));
            else
              talign = DECL_ALIGN_UNIT (ovar);
@@ -16276,7 +16268,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 (is_reference (ovar))
+           if (omp_is_reference (ovar))
              type = TREE_TYPE (type);
            if ((INTEGRAL_TYPE_P (type)
                 && TYPE_PRECISION (type) <= POINTER_SIZE)
@@ -16284,7 +16276,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
              {
                tkind = GOMP_MAP_FIRSTPRIVATE_INT;
                tree t = var;
-               if (is_reference (var))
+               if (omp_is_reference (var))
                  t = build_simple_mem_ref (var);
                else if (OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (c))
                  TREE_NO_WARNING (var) = 1;
@@ -16293,7 +16285,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 (is_reference (var))
+           else if (omp_is_reference (var))
              gimplify_assign (x, var, &ilist);
            else if (is_gimple_reg (var))
              {
@@ -16312,7 +16304,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
              }
            if (tkind == GOMP_MAP_FIRSTPRIVATE_INT)
              s = size_int (0);
-           else if (is_reference (var))
+           else if (omp_is_reference (var))
              s = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ovar)));
            else
              s = TYPE_SIZE_UNIT (TREE_TYPE (ovar));
@@ -16346,7 +16338,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
              var = build_fold_addr_expr (var);
            else
              {
-               if (is_reference (ovar))
+               if (omp_is_reference (ovar))
                  {
                    type = TREE_TYPE (type);
                    if (TREE_CODE (type) != ARRAY_TYPE)
@@ -16425,13 +16417,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 (is_reference (var)
+           if (omp_is_reference (var)
                || is_gimple_reg_type (TREE_TYPE (var)))
              {
                tree new_var = lookup_decl (var, ctx);
                tree type;
                type = TREE_TYPE (var);
-               if (is_reference (var))
+               if (omp_is_reference (var))
                  type = TREE_TYPE (type);
                if ((INTEGRAL_TYPE_P (type)
                     && TYPE_PRECISION (type) <= POINTER_SIZE)
@@ -16443,7 +16435,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 (is_reference (var))
+                   if (omp_is_reference (var))
                      {
                        tree v = create_tmp_var_raw (type, get_name (var));
                        gimple_add_tmp_var (v);
@@ -16457,7 +16449,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
                  }
                else
                  {
-                   x = build_receiver_ref (var, !is_reference (var), ctx);
+                   x = build_receiver_ref (var, !omp_is_reference (var), ctx);
                    gimplify_expr (&x, &new_body, NULL, is_gimple_val,
                                   fb_rvalue);
                    gimple_seq_add_stmt (&new_body,
@@ -16481,7 +16473,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 (is_reference (var))
+           if (omp_is_reference (var))
              {
                location_t clause_loc = OMP_CLAUSE_LOCATION (c);
                tree new_var = lookup_decl (var, ctx);
@@ -16536,7 +16528,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
              {
                tree type = TREE_TYPE (var);
                tree new_var = lookup_decl (var, ctx);
-               if (is_reference (var))
+               if (omp_is_reference (var))
                  {
                    type = TREE_TYPE (type);
                    if (TREE_CODE (type) != ARRAY_TYPE)
@@ -16625,7 +16617,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
                                                     offset));
                  }
                else
-                 is_ref = is_reference (var);
+                 is_ref = omp_is_reference (var);
                if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_REFERENCE)
                  is_ref = false;
                bool ref_to_array = false;
@@ -16705,7 +16697,7 @@ 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 (is_reference (var) && !is_gimple_omp_oacc (ctx->stmt))
+           else if (omp_is_reference (var) && !is_gimple_omp_oacc (ctx->stmt))
              {
                location_t clause_loc = OMP_CLAUSE_LOCATION (c);
                tree new_var = lookup_decl (var, ctx);
diff --git gcc/omp-low.h gcc/omp-low.h
index b1f7885..a7bfc03 100644
--- gcc/omp-low.h
+++ gcc/omp-low.h
@@ -20,6 +20,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_OMP_LOW_H
 #define GCC_OMP_LOW_H
 
+#include "langhooks.h"
+
 struct omp_region;
 
 extern tree find_omp_clause (tree, enum omp_clause_code);
@@ -41,4 +43,12 @@ extern int get_oacc_fn_dim_size (tree, int);
 extern GTY(()) vec<tree, va_gc> *offload_funcs;
 extern GTY(()) vec<tree, va_gc> *offload_vars;
 
+/* Return true if DECL is a reference type.  */
+
+static inline bool
+omp_is_reference (tree decl)
+{
+  return lang_hooks.decls.omp_privatize_by_reference (decl);
+}
+
 #endif /* GCC_OMP_LOW_H */


Grüße
 Thomas

Reply via email to