]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
Fix lexically-nested data mappings for no_alloc or optional arguments
authorJulian Brown <julian@codesourcery.com>
Tue, 21 May 2019 00:27:38 +0000 (17:27 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 21 Jun 2022 13:11:15 +0000 (14:11 +0100)
gcc/
* gimplify.cc (gimplify_adjust_omp_clauses_1): Support implied no_alloc
and optional arguments based on mappings in enclosing data regions.

gcc/ChangeLog.omp
gcc/gimplify.cc

index 286ff0fda02c8b2b3a4992c5c274222e1d370d87..40d7e5ad8a570f75045b0483bab248546163cb36 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-20  Julian Brown  <julian@codesourcery.com>
+
+       * gimplify.cc (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.cc (oacc_array_mapping_info): Add REF field.
index 355b5b0bf56fe9066ff9e272e60dc8580310b80c..477576ff0e7864515c6db8a232a0e15019c1ea67 100644 (file)
@@ -11336,9 +11336,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.  */
@@ -11353,7 +11356,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));