]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: OpenMP/OpenACC array mapping alignment fix (PR90030)
authorChung-Lin Tang <cltang@codesourcery.com>
Thu, 2 Dec 2021 10:24:03 +0000 (18:24 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Wed, 8 Dec 2021 14:17:27 +0000 (22:17 +0800)
commit8f7d25feef166299fb9da89281ec857c565782dd
tree654b369d3736458b0020deaa68a46aa4bbf8e2f3
parent3fb6b575593f29dc5d9daba457deb6ec4b932667
fortran: OpenMP/OpenACC array mapping alignment fix (PR90030)

Fix issue with the Fortran front-end when mapping arrays: when creating the
data MEM_REF for the map clause, there was a convention of casting the
referencing pointer to 'c_char *' by
fold_convert (build_pointer_type (char_type_node), ptr).

This causes the alignment passed to the libgomp runtime for array data
hardwared to '1', and causes alignment errors on the offload target.

This patch fixes this by removing the char_type_node pointer converts, and
adding gcc_asserts to ensure POINTER_TYPE_P (TREE_TYPE (ptr)).

PR fortran/90030

gcc/fortran/ChangeLog:

* trans-openmp.c (gfc_omp_finish_clause): Remove fold_convert to pointer
to char_type_node, add gcc_assert of POINTER_TYPE_P.
(gfc_trans_omp_array_section): Likewise.
(gfc_trans_omp_clauses): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/finalize-1.f: Adjust scan test.
* gfortran.dg/gomp/affinity-clause-1.f90: Likewise.
* gfortran.dg/gomp/affinity-clause-5.f90: Likewise.
* gfortran.dg/gomp/defaultmap-4.f90: Likewise.
* gfortran.dg/gomp/defaultmap-5.f90: Likewise.
* gfortran.dg/gomp/defaultmap-6.f90: Likewise.
* gfortran.dg/gomp/map-3.f90: Likewise.
* gfortran.dg/gomp/pr78260-2.f90: Likewise.
* gfortran.dg/gomp/pr78260-3.f90: Likewise.

libgomp/ChangeLog:

* testsuite/libgomp.oacc-fortran/pr90030.f90: New test.
* testsuite/libgomp.fortran/pr90030.f90: New test.

(cherry picked from commit 1ac7a8c9e4798d352eb8c64905dd38086af4e1cd)
12 files changed:
gcc/fortran/trans-openmp.c
gcc/testsuite/gfortran.dg/goacc/finalize-1.f
gcc/testsuite/gfortran.dg/gomp/affinity-clause-1.f90
gcc/testsuite/gfortran.dg/gomp/affinity-clause-5.f90
gcc/testsuite/gfortran.dg/gomp/defaultmap-4.f90
gcc/testsuite/gfortran.dg/gomp/defaultmap-5.f90
gcc/testsuite/gfortran.dg/gomp/defaultmap-6.f90
gcc/testsuite/gfortran.dg/gomp/map-3.f90
gcc/testsuite/gfortran.dg/gomp/pr78260-2.f90
gcc/testsuite/gfortran.dg/gomp/pr78260-3.f90
libgomp/testsuite/libgomp.fortran/pr90030.f90 [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-fortran/pr90030.f90 [new file with mode: 0644]