public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Kwok Yeung <kcy@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] Fix lexically-nested data mappings for no_alloc or optional arguments
Date: Thu, 13 May 2021 16:10:53 +0000 (GMT)	[thread overview]
Message-ID: <20210513161053.127E53A3E400@sourceware.org> (raw)

https://gcc.gnu.org/g:1830597eb50a404f67081019ce5f5ae69e528b5a

commit 1830597eb50a404f67081019ce5f5ae69e528b5a
Author: Julian Brown <julian@codesourcery.com>
Date:   Mon May 20 17:27:38 2019 -0700

    Fix lexically-nested data mappings for no_alloc or optional arguments
    
            gcc/
            * gimplify.c (gimplify_adjust_omp_clauses_1): Support implied no_alloc
            and optional arguments based on mappings in enclosing data regions.

Diff:
---
 gcc/ChangeLog.omp |  5 +++++
 gcc/gimplify.c    | 12 ++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index eabcfb9e44b..f98933fd60f 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2019-05-20  Julian Brown  <julian@codesourcery.com>
+
+	* gimplify.c (gimplify_adjust_omp_clauses_1): Support implied no_alloc
+	and optional arguments based on mappings in enclosing data regions.
+
 2019-05-19  Julian Brown  <julian@codesourcery.com>
 
 	* gimplify.c (oacc_array_mapping_info): Add REF field.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 5b9e51ea785..28fb659536d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -10449,9 +10449,12 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
     {
       tree mapping = array_info->mapping;
       tree pointer = array_info->pointer;
-      const gomp_map_kind presence_kind
-	= omp_check_optional_argument (decl, false) ? GOMP_MAP_IF_PRESENT
-						    : GOMP_MAP_FORCE_PRESENT;
+      gomp_map_kind presence_kind = GOMP_MAP_FORCE_PRESENT;
+      bool no_alloc = (OMP_CLAUSE_CODE (mapping) == OMP_CLAUSE_MAP
+		       && OMP_CLAUSE_MAP_KIND (mapping) == GOMP_MAP_IF_PRESENT);
+
+      if (no_alloc || omp_check_optional_argument (decl, false))
+        presence_kind = GOMP_MAP_IF_PRESENT;
 
       if (code == OMP_CLAUSE_FIRSTPRIVATE)
 	/* Oops, we have the wrong type of clause.  Rebuild it.  */
@@ -10466,7 +10469,8 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
       tree nc = build_omp_clause (OMP_CLAUSE_LOCATION (clause),
 				  OMP_CLAUSE_MAP);
       OMP_CLAUSE_DECL (nc) = unshare_expr (OMP_CLAUSE_DECL (pointer));
-      OMP_CLAUSE_SET_MAP_KIND (nc, GOMP_MAP_POINTER);
+      OMP_CLAUSE_SET_MAP_KIND (nc, no_alloc ? GOMP_MAP_FIRSTPRIVATE_POINTER
+					    : GOMP_MAP_POINTER);
 
       /* For GOMP_MAP_FIRSTPRIVATE_POINTER, this is a bias, not a size.  */
       OMP_CLAUSE_SIZE (nc) = unshare_expr (OMP_CLAUSE_SIZE (pointer));


                 reply	other threads:[~2021-05-13 16:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210513161053.127E53A3E400@sourceware.org \
    --to=kcy@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).