mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-21 19:35:28 -05:00
This patch generates calls to GOMP_alloc to allocate memory for firstprivate and private clauses on target constructs with an allocator and alignment as specified by the allocate clause. The decl values of the clause need to be adjusted to refer to the allocated memory, and the initial values of variables need to be copied into the allocated space for firstprivate variables. For variable-length arrays, the size of the array is stored in a separate variable, so the allocation and initialization need to be delayed until the size is made available on the target. gcc/ PR middle-end/113436 * omp-low.cc (is_variable_sized): Add extra is_ref argument. Check referenced type if true. (lower_omp_target): Call lower_private_allocate to generate code to allocate memory for firstprivate/private clauses with allocators, and insert code after dependent variables have been initialized. Construct calls to free allocate memory and insert after target block. Adjust decl values for clause variables. Copy value of firstprivate variables to allocated memory. gcc/testsuite/ PR middle-end/113436 * c-c++-common/gomp/pr113436-1.c: New. * c-c++-common/gomp/pr113436-2.c: New. * g++.dg/gomp/pr113436.C: New. * gfortran.dg/gomp/pr113436-1.f90: New. * gfortran.dg/gomp/pr113436-2.f90: New. * gfortran.dg/gomp/pr113436-3.f90: New. * gfortran.dg/gomp/pr113436-4.f90: New. libgomp/ PR middle-end/113436 * libgomp.texi (OpenMP 5.0): Mark allocate clause as implemented. (Memory allocation): Add documentation for use in target construct. * testsuite/libgomp.c++/firstprivate-1.C: Enable alignment check. * testsuite/libgomp.c++/pr113436-1.C: New. * testsuite/libgomp.c++/pr113436-2.C: New. * testsuite/libgomp.c++/private-1.C: Enable alignment check. * testsuite/libgomp.c-c++-common/pr113436-1.c: New. * testsuite/libgomp.c-c++-common/pr113436-2.c: New. * testsuite/libgomp.fortran/pr113436-1.f90: New. * testsuite/libgomp.fortran/pr113436-2.f90: New.