public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-10] Merge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10
Date: Mon, 15 Jun 2020 16:54:58 +0000 (GMT)	[thread overview]
Message-ID: <20200615165458.376F9388A80F@sourceware.org> (raw)

https://gcc.gnu.org/g:4c83afa73298449e479110c98696ff83193eff85

commit 4c83afa73298449e479110c98696ff83193eff85
Merge: cd7b511ace0 8a3453786c3
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Jun 15 17:57:43 2020 +0200

    Merge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10
    
    Merged up to 8a3453786c3c2d6343c5258e564ad139d5ad116f (Jun 15, 2020)

Diff:

 gcc/ChangeLog                                    | 30 ++++++++
 gcc/DATESTAMP                                    |  2 +-
 gcc/c-family/ChangeLog                           |  6 ++
 gcc/c-family/c-pretty-print.c                    |  5 +-
 gcc/config/gcn/gcn-valu.md                       |  2 +-
 gcc/cp/ChangeLog                                 | 21 ++++++
 gcc/cp/coroutines.cc                             | 13 +---
 gcc/cp/cp-gimplify.c                             | 94 ++++++++++++++++++++----
 gcc/cp/decl.c                                    |  2 +
 gcc/fortran/ChangeLog                            | 38 ++++++++++
 gcc/fortran/check.c                              | 61 +++++++++++----
 gcc/fortran/class.c                              | 18 ++++-
 gcc/fortran/expr.c                               |  4 +-
 gcc/fortran/gfortran.h                           | 19 ++++-
 gcc/fortran/intrinsic.c                          | 12 +++
 gcc/fortran/symbol.c                             | 12 +++
 gcc/gimplify.c                                   | 56 --------------
 gcc/lto-cgraph.c                                 |  8 ++
 gcc/omp-general.c                                | 56 ++++++++++++++
 gcc/omp-general.h                                |  1 +
 gcc/omp-offload.c                                | 12 ++-
 gcc/testsuite/ChangeLog                          | 58 +++++++++++++++
 gcc/testsuite/g++.dg/cpp0x/initlist-array12.C    |  4 +-
 gcc/testsuite/g++.dg/cpp1z/decomp53.C            | 22 ++++++
 gcc/testsuite/g++.dg/opt/pr95528.C               | 27 +++++++
 gcc/testsuite/gcc.dg/pr95580.c                   | 16 ++++
 gcc/testsuite/gfortran.dg/finalize_34.f90        |  2 +-
 gcc/testsuite/gfortran.dg/finalize_36.f90        | 39 ++++++++++
 gcc/testsuite/gfortran.dg/pr93366.f90            | 18 +++++
 gcc/testsuite/gfortran.dg/pr95503.f90            |  7 ++
 gcc/testsuite/gfortran.dg/pr95544.f90            | 15 ++++
 gcc/tree-ssa-forwprop.c                          | 11 +++
 libgomp/testsuite/libgomp.fortran/target-var.f90 | 32 ++++++++
 33 files changed, 613 insertions(+), 110 deletions(-)

diff --cc gcc/cp/cp-gimplify.c
index 65ed2f5c6b2,11b836f7bb9..cc6eb2be3af
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@@ -1340,6 -1646,75 +1341,83 @@@ cp_genericize_r (tree *stmt_p, int *wal
        *stmt_p = genericize_spaceship (*stmt_p);
        break;
  
+     case OMP_DISTRIBUTE:
+       /* Need to explicitly instantiate copy ctors on class iterators of
+ 	 composite distribute parallel for.  */
+       if (OMP_FOR_INIT (*stmt_p) == NULL_TREE)
+ 	{
+ 	  tree *data[4] = { NULL, NULL, NULL, NULL };
+ 	  tree inner = walk_tree (&OMP_FOR_BODY (*stmt_p),
+ 				  find_combined_omp_for, data, NULL);
+ 	  if (inner != NULL_TREE
+ 	      && TREE_CODE (inner) == OMP_FOR)
+ 	    {
+ 	      for (int i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (inner)); i++)
+ 		if (OMP_FOR_ORIG_DECLS (inner)
+ 		    && TREE_CODE (TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (inner),
+ 				  i)) == TREE_LIST
+ 		    && TREE_PURPOSE (TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (inner),
+ 				     i)))
+ 		  {
+ 		    tree orig = TREE_VEC_ELT (OMP_FOR_ORIG_DECLS (inner), i);
+ 		    /* Class iterators aren't allowed on OMP_SIMD, so the only
+ 		       case we need to solve is distribute parallel for.  */
+ 		    gcc_assert (TREE_CODE (inner) == OMP_FOR
+ 				&& data[1]);
+ 		    tree orig_decl = TREE_PURPOSE (orig);
+ 		    tree c, cl = NULL_TREE;
+ 		    for (c = OMP_FOR_CLAUSES (inner);
+ 			 c; c = OMP_CLAUSE_CHAIN (c))
+ 		      if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
+ 			   || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE)
+ 			  && OMP_CLAUSE_DECL (c) == orig_decl)
+ 			{
+ 			  cl = c;
+ 			  break;
+ 			}
+ 		    if (cl == NULL_TREE)
+ 		      {
+ 			for (c = OMP_PARALLEL_CLAUSES (*data[1]);
+ 			     c; c = OMP_CLAUSE_CHAIN (c))
+ 			  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE
+ 			      && OMP_CLAUSE_DECL (c) == orig_decl)
+ 			    {
+ 			      cl = c;
+ 			      break;
+ 			    }
+ 		      }
+ 		    if (cl)
+ 		      {
+ 			orig_decl = require_complete_type (orig_decl);
+ 			tree inner_type = TREE_TYPE (orig_decl);
+ 			if (orig_decl == error_mark_node)
+ 			  continue;
+ 			if (TYPE_REF_P (TREE_TYPE (orig_decl)))
+ 			  inner_type = TREE_TYPE (inner_type);
+ 
+ 			while (TREE_CODE (inner_type) == ARRAY_TYPE)
+ 			  inner_type = TREE_TYPE (inner_type);
+ 			get_copy_ctor (inner_type, tf_warning_or_error);
+ 		      }
+ 		}
+ 	    }
+ 	}
+       /* FALLTHRU */
++    case FOR_STMT:
++    case WHILE_STMT:
++    case DO_STMT:
++    case SWITCH_STMT:
++    case CONTINUE_STMT:
++    case BREAK_STMT:
+     case OMP_FOR:
+     case OMP_SIMD:
+     case OMP_LOOP:
+     case OACC_LOOP:
 -      genericize_omp_for_stmt (stmt_p, walk_subtrees, data);
++      /* These cases are handled by shared code.  */
++      c_genericize_control_stmt (stmt_p, walk_subtrees, data,
++				 cp_genericize_r, cp_walk_subtrees);
+       break;
+ 
      case PTRMEM_CST:
        /* By the time we get here we're handing off to the back end, so we don't
  	 need or want to preserve PTRMEM_CST anymore.  */
diff --cc gcc/gimplify.c
index 3defdb70fa0,ff40cf13769..37ea9e0673c
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@@ -11219,152 -10987,6 +11219,96 @@@ gimplify_omp_task (tree *expr_p, gimple
    *expr_p = NULL_TREE;
  }
  
- /* Helper function of gimplify_omp_for, find OMP_FOR resp. OMP_SIMD
-    with non-NULL OMP_FOR_INIT.  Also, fill in pdata array,
-    pdata[0] non-NULL if there is anything non-trivial in between, pdata[1]
-    is address of OMP_PARALLEL in between if any, pdata[2] is address of
-    OMP_FOR in between if any and pdata[3] is address of the inner
-    OMP_FOR/OMP_SIMD.  */
- 
- static tree
- find_combined_omp_for (tree *tp, int *walk_subtrees, void *data)
- {
-   tree **pdata = (tree **) data;
-   *walk_subtrees = 0;
-   switch (TREE_CODE (*tp))
-     {
-     case OMP_FOR:
-       if (OMP_FOR_INIT (*tp) != NULL_TREE)
- 	{
- 	  pdata[3] = tp;
- 	  return *tp;
- 	}
-       pdata[2] = tp;
-       *walk_subtrees = 1;
-       break;
-     case OMP_SIMD:
-       if (OMP_FOR_INIT (*tp) != NULL_TREE)
- 	{
- 	  pdata[3] = tp;
- 	  return *tp;
- 	}
-       break;
-     case BIND_EXPR:
-       if (BIND_EXPR_VARS (*tp)
- 	  || (BIND_EXPR_BLOCK (*tp)
- 	      && BLOCK_VARS (BIND_EXPR_BLOCK (*tp))))
- 	pdata[0] = tp;
-       *walk_subtrees = 1;
-       break;
-     case STATEMENT_LIST:
-       if (!tsi_one_before_end_p (tsi_start (*tp)))
- 	pdata[0] = tp;
-       *walk_subtrees = 1;
-       break;
-     case TRY_FINALLY_EXPR:
-       pdata[0] = tp;
-       *walk_subtrees = 1;
-       break;
-     case OMP_PARALLEL:
-       pdata[1] = tp;
-       *walk_subtrees = 1;
-       break;
-     default:
-       break;
-     }
-   return NULL_TREE;
- }
- 
 +/* Helper function for localize_reductions.  Replace all uses of REF_VAR with
 +   LOCAL_VAR.  */
 +
 +static tree
 +localize_reductions_r (tree *tp, int *walk_subtrees, void *data)
 +{
 +  enum tree_code tc = TREE_CODE (*tp);
 +  struct privatize_reduction *pr = (struct privatize_reduction *) data;
 +
 +  if (TYPE_P (*tp))
 +    *walk_subtrees = 0;
 +
 +  switch (tc)
 +    {
 +    case INDIRECT_REF:
 +    case MEM_REF:
 +      if (TREE_OPERAND (*tp, 0) == pr->ref_var)
 +	*tp = pr->local_var;
 +
 +      *walk_subtrees = 0;
 +      break;
 +
 +    case VAR_DECL:
 +    case PARM_DECL:
 +    case RESULT_DECL:
 +      if (*tp == pr->ref_var)
 +	*tp = pr->local_var;
 +
 +      *walk_subtrees = 0;
 +      break;
 +
 +    default:
 +      break;
 +    }
 +
 +  return NULL_TREE;
 +}
 +
 +/* OpenACC worker and vector loop state propagation requires reductions
 +   to be inside local variables.  This function replaces all reference-type
 +   reductions variables associated with the loop with a local copy.  It is
 +   also used to create private copies of reduction variables for those
 +   which are not associated with acc loops.  */
 +
 +static void
 +localize_reductions (tree clauses, tree body)
 +{
 +  tree c, var, type, new_var;
 +  struct privatize_reduction pr;
 +
 +  for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
 +    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
 +      {
 +	var = OMP_CLAUSE_DECL (c);
 +
 +	if (!lang_hooks.decls.omp_privatize_by_reference (var))
 +	  {
 +	    OMP_CLAUSE_REDUCTION_PRIVATE_DECL (c) = NULL;
 +	    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);
 +
 +	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));
 +	if (TREE_CODE (type) == ARRAY_TYPE)
 +	  continue;
 +	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);
 +      }
 +}
 +
 +
  /* Gimplify the gross structure of an OMP_FOR statement.  */
  
  static enum gimplify_status


             reply	other threads:[~2020-06-15 16:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 16:54 Tobias Burnus [this message]
2020-06-18 20:39 Tobias Burnus
2020-07-14 10:59 Tobias Burnus
2020-08-21  8:04 Tobias Burnus
2020-08-21 15:18 Tobias Burnus
2020-08-25 12:56 Tobias Burnus
2020-09-01 10:01 Tobias Burnus
2020-09-09 10:14 Tobias Burnus
2020-09-11 11:43 Tobias Burnus
2020-09-15  8:44 Tobias Burnus
2020-09-15 19:48 Tobias Burnus
2020-09-16 14:51 Tobias Burnus
2020-09-17 17:03 Tobias Burnus
2020-09-28 18:28 Tobias Burnus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200615165458.376F9388A80F@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).