[OpenMP] Fix 'omp exit data' for Fortran arrays (PR 94635)
authorTobias Burnus <tobias@codesourcery.com>
Fri, 15 May 2020 09:50:34 +0000 (11:50 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 15 May 2020 09:54:02 +0000 (11:54 +0200)
gcc/
PR middle-end/94635
* gimplify.c (gimplify_scan_omp_clauses): For MAP_TO_PSET with
OMP_TARGET_EXIT_DATA, use 'release:' unless the associated
item is 'delete:'.

gcc/testsuite
PR middle-end/94635
* gfortran.dg/gomp/target-exit-data.f90: New.

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/gomp/target-exit-data.f90 [new file with mode: 0644]

index 587db3969cd94857b686e73a067fe01106395cf5..592ca9bfd31919ec0b26dd9fd161cd4d22682fd0 100644 (file)
@@ -1,3 +1,10 @@
+2020-05-15  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR middle-end/94635
+       * gimplify.c (gimplify_scan_omp_clauses): For MAP_TO_PSET with
+       OMP_TARGET_EXIT_DATA, use 'release:' unless the associated
+       item is 'delete:'.
+
 2020-05-15  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/95046
index 1d532e6f373956e6394c253b43c1dc998398e33b..e104e766517eb9ddf7b918dbe65cefe3a6185049 100644 (file)
@@ -8766,7 +8766,9 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
             to be delete; hence, we turn the MAP_TO_PSET into a MAP_DELETE.  */
          if (code == OMP_TARGET_EXIT_DATA
              && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_TO_PSET)
-           OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_DELETE);
+           OMP_CLAUSE_SET_MAP_KIND (c, OMP_CLAUSE_MAP_KIND (*prev_list_p)
+                                       == GOMP_MAP_DELETE
+                                       ? GOMP_MAP_DELETE : GOMP_MAP_RELEASE);
          else if ((code == OMP_TARGET_EXIT_DATA || code == OMP_TARGET_UPDATE)
                   && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
                       || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_TO_PSET))
index 4a7988f8a5c7f3dee2f6e2c333f3ca075e50ee6b..6b8b52dae2ec4e099e1158799a7a0d1f8711cf5b 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-15  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR middle-end/94635
+       * gfortran.dg/gomp/target-exit-data.f90: New.
+
 2020-05-15  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/95046
diff --git a/gcc/testsuite/gfortran.dg/gomp/target-exit-data.f90 b/gcc/testsuite/gfortran.dg/gomp/target-exit-data.f90
new file mode 100644 (file)
index 0000000..ed57d00
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-omplower" }
+!
+! PR middle-end/94635
+
+integer, allocatable :: one(:), two(:), three(:)
+
+!$omp target enter data map(alloc:one)
+!$omp target enter data map(alloc:two)
+!$omp target enter data map(to:three)
+
+! ...
+!$omp target exit data map(delete:one)
+!$omp target exit data map(release:two)
+!$omp target exit data map(from:three)
+end
+
+! { dg-final { scan-tree-dump "omp target exit data map\\(delete:.*\\) map\\(delete:one \\\[len: .*\\\]\\)" "omplower" } }
+! { dg-final { scan-tree-dump "omp target exit data map\\(release:.*\\) map\\(release:two \\\[len: .*\\\]\\)" "omplower" } }
+! { dg-final { scan-tree-dump "omp target exit data map\\(from:.*\\) map\\(release:three \\\[len: .*\\\]\\)" "omplower" } }