OpenMP/Fortran: Use firstprivat not alloc for ptr attach for arrays
authorTobias Burnus <tobias@codesourcery.com>
Fri, 13 May 2022 18:00:34 +0000 (20:00 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 13 May 2022 18:00:34 +0000 (20:00 +0200)
commita46d6268371c446566f656858aada8775a0c988e
treed8a936caa2c14b43489d72edb77c5be0e1981c8e
parentbc25483c055d62f94f8c289f80843dda3c4a6ff4
OpenMP/Fortran: Use firstprivat not alloc for ptr attach for arrays

For a non-descriptor array,  map(A(n:m)) was mapped as
  map(tofrom:A[n-1] [len: ...]) map(alloc:A [pointer assign, bias: ...])
with this patch, it is changed to
  map(tofrom:A[n-1] [len: ...]) map(firstprivate:A [pointer assign, bias: ...])

The latter avoids an alloc - and also avoids the race condition with
nowait in the enclosed testcase. (Note: predantically, the testcase is
invalid since OpenMP 5.1, violating the map clause restriction at [354:10-13].

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_trans_omp_clauses): When mapping nondescriptor
array sections, use GOMP_MAP_FIRSTPRIVATE_POINTER instead of
GOMP_MAP_POINTER for the pointer attachment.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/target-nowait-array-section.f90: New test.
gcc/fortran/trans-openmp.cc
libgomp/testsuite/libgomp.fortran/target-nowait-array-section.f90 [new file with mode: 0644]