[Bug fortran/120505] [OpenMP] Fortran deep mapping of alloc comp + component mapping like 'map(var%arr(1)%alloc)' in target (enter/exit) data
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 23 13:18:05 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120505
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul-Antoine Arras <parras@gcc.gnu.org>:
https://gcc.gnu.org/g:99cfdcee2fe9b0f5230f17fd3226825259171138
commit r16-7646-g99cfdcee2fe9b0f5230f17fd3226825259171138
Author: Paul-Antoine Arras <parras@baylibre.com>
Date: Fri Feb 20 14:21:29 2026 +0100
OpenMP/Fortran: Map intermediate array descriptors [PR120505]
Consider the following OMP directive, assuming tiles is allocatable:
!$omp target enter data &
!$omp map(to: chunk%tiles(1)%field%density0) &
!$omp map(to: chunk%left_rcv_buffer)
libgomp reports an illegal memory access error at runtime. This is because
density0 is referenced through tiles, which requires its descriptor to be
mapped
along its content.
This patch ensures that all such intervening allocatables in a reference
chain
are properly mapped. For the above example, the frontend has to create the
following three additional map clauses:
(1) map (alloc: *(struct tile_type[0:] * restrict) chunk.tiles.data [len:
0])
(2) map (to: chunk.tiles [pointer set, len: 64])
(3) map (attach_detach: (struct tile_type[0:] * restrict) chunk.tiles.data
[bias: -1])
(1) is required by the gimplifier for attaching but will be removed at the
end
of the pass; the inner component is explicitly to-mapped elsewhere. (2)
ensures
that the array descriptor will be available at runtime to compute offsets
and
strides in various dimensions. The gimplifier will turn (3) into a regular
attach of the data pointer and compute the bias.
PR fortran/120505
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_map_array_descriptor): New function.
(gfc_trans_omp_clauses): Emit map clauses for intermediate array
descriptors.
gcc/ChangeLog:
* gimplify.cc (omp_mapped_by_containing_struct): Handle Fortran
array
descriptors.
(omp_build_struct_sibling_lists): Allow attach_detach bias to be
adjusted on non-target regions.
(gimplify_adjust_omp_clauses): Remove GIMPLE-only nodes.
* tree-pretty-print.cc (dump_omp_clause): Handle
OMP_CLAUSE_MAP_SIZE_NEEDS_ADJUSTMENT and
OMP_CLAUSE_MAP_GIMPLE_ONLY.
* tree.h (OMP_CLAUSE_MAP_SIZE_NEEDS_ADJUSTMENT,
OMP_CLAUSE_MAP_GIMPLE_ONLY): Define.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/map-subarray-11.f90: New test.
* testsuite/libgomp.fortran/map-subarray-13.f90: New test.
* testsuite/libgomp.fortran/map-subarray-14.f90: New test.
* testsuite/libgomp.fortran/map-subarray-15.f90: New test.
* testsuite/libgomp.fortran/map-subarray-16.f90: New test.
* testsuite/libgomp.fortran/map-alloc-present-2.f90: New file.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/map-subarray-3.f90: New test.
* gfortran.dg/gomp/map-subarray-5.f90: New test.
More information about the Gcc-bugs
mailing list