https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113436

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kwok Yeung <[email protected]>:

https://gcc.gnu.org/g:6eec7a3687aa8195eaf6b7f6694b50ece17590c5

commit r16-7481-g6eec7a3687aa8195eaf6b7f6694b50ece17590c5
Author: Kwok Cheung Yeung <[email protected]>
Date:   Thu Feb 12 14:48:03 2026 +0000

    openmp: Allocate memory for private/firstprivate clauses as directed by
allocate clauses in target constructs [PR113436]

    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.

Reply via email to