It never makes sense for a GOMP_MAP_ATTACH_DETACH mapping to survive
beyond gimplify.c, and with OpenMP making use of that mapping type too
now alongside OpenACC, there are cases where it was making it through
to omp-low.c.  This patch rewrites such mappings to GOMP_MAP_ATTACH or
GOMP_MAP_DETACH unconditionally for both OpenACC and OpenMP, in cases
where it hasn't otherwise been handled already in the preceding code.

2021-05-11  Julian Brown  <jul...@codesourcery.com>

gcc/
        * gimplify.c (gimplify_scan_omp_clauses): Remove OpenACC-only
        condition for changing GOMP_MAP_ATTACH_DETACH to GOMP_MAP_ATTACH or
        GOMP_MAP_DETACH.  Use detach for OMP_TARGET_EXIT_DATA also.
---
 gcc/gimplify.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c2072c7188f..86000f8470b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9695,16 +9695,11 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq 
*pre_p,
                  if (cont)
                    continue;
                }
-             else if ((code == OACC_ENTER_DATA
-                       || code == OACC_EXIT_DATA
-                       || code == OACC_DATA
-                       || code == OACC_PARALLEL
-                       || code == OACC_KERNELS
-                       || code == OACC_SERIAL)
-                      && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH_DETACH)
+             else if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH_DETACH)
                {
-                 gomp_map_kind k = (code == OACC_EXIT_DATA
-                                    ? GOMP_MAP_DETACH : GOMP_MAP_ATTACH);
+                 gomp_map_kind k
+                   = ((code == OACC_EXIT_DATA || code == OMP_TARGET_EXIT_DATA)
+                      ? GOMP_MAP_DETACH : GOMP_MAP_ATTACH);
                  OMP_CLAUSE_SET_MAP_KIND (c, k);
                }
 
-- 
2.29.2

Reply via email to