]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: Allocate directive for static vars, clean up
authorTobias Burnus <tburnus@baylibre.com>
Mon, 7 Oct 2024 08:45:14 +0000 (10:45 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Mon, 7 Oct 2024 08:45:14 +0000 (10:45 +0200)
commita8caeaacf499d58ba7ceabc311b7b71ca806f740
treee37c465657b7d057ea35929116672d3e29aa4104
parentb137e4bbcc488b44a037baad62a8da90659d7468
OpenMP: Allocate directive for static vars, clean up

For the 'allocate' directive, remove the sorry for static variables and
just keep using normal memory, but honor the requested alignment and set
a DECL_ATTRIBUTE in case a target may want to make use of this later on.
The documentation is updated accordingly.

The C diagnostic to check for predefined allocators (req. for static vars)
failed to accept GCC's ompx_gnu_... allocator, now fixed. (Fortran was
already okay; but both now use new common #defined value for checking.)
And while Fortran common block variables are still rejected, the check
has been improved as before the sorry diagnostic did not work for
common blocks in modules.

Finally, for 'allocate' clause on the target/task/taskloop directives,
there is now a warning for omp_thread_mem_alloc (i.e. predefined allocator
with access = thread), which is undefined behavior according to the
OpenMP specification.

And, last, testing showed that var decl + static_assert sets TREE_USED
but does not produce a statement list in C, which did run into an assert
in gimplify. This special case is now also handled.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_allocate): Set alignment for alignof;
accept static variables and fix predef allocator check.

gcc/fortran/ChangeLog:

* openmp.cc (is_predefined_allocator): Use gomp-constants.h consts.
* trans-common.cc (translate_common): Reject OpenMP allocate directives.
* trans-decl.cc (gfc_finish_var_decl): Handle allocate directive
for static variables.
(gfc_trans_deferred_vars): Update for the latter.

gcc/ChangeLog:

* gimplify.cc (gimplify_bind_expr): Fix corner case for OpenMP
allocate directive.
(gimplify_scan_omp_clauses): Warn if omp_thread_mem_alloc is used
as allocator with the target/task/taskloop directive.

include/ChangeLog:

* gomp-constants.h (GOMP_OMP_PREDEF_ALLOC_MAX,
GOMP_OMPX_PREDEF_ALLOC_MIN, GOMP_OMPX_PREDEF_ALLOC_MAX,
GOMP_OMP_PREDEF_ALLOC_THREADS): New defines.

libgomp/ChangeLog:

* allocator.c: Add static asserts for news
GOMP_OMP{,X}_PREDEF_ALLOC_{MIN,MAX} range values.
* libgomp.texi (OpenMP Impl. Status): Allocate directive for
static vars is now supported. Refer to PR for allocate clause.
(Memory allocation): Update for static vars; minor word tweaking.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/allocate-9.c: Update for removed sorry.
* gfortran.dg/gomp/allocate-15.f90: Likewise.
* gfortran.dg/gomp/allocate-pinned-1.f90: Likewise.
* gfortran.dg/gomp/allocate-4.f90: Likewise; add dg-error for
previously missing diagnostic.
* c-c++-common/gomp/allocate-18.c: New test.
* c-c++-common/gomp/allocate-19.c: New test.
* gfortran.dg/gomp/allocate-clause.f90: New test.
* gfortran.dg/gomp/allocate-static-2.f90: New test.
* gfortran.dg/gomp/allocate-static.f90: New test.
17 files changed:
gcc/c/c-parser.cc
gcc/fortran/openmp.cc
gcc/fortran/trans-common.cc
gcc/fortran/trans-decl.cc
gcc/gimplify.cc
gcc/testsuite/c-c++-common/gomp/allocate-18.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/allocate-19.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/allocate-9.c
gcc/testsuite/gfortran.dg/gomp/allocate-15.f90
gcc/testsuite/gfortran.dg/gomp/allocate-4.f90
gcc/testsuite/gfortran.dg/gomp/allocate-clause.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/allocate-pinned-1.f90
gcc/testsuite/gfortran.dg/gomp/allocate-static-2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/allocate-static.f90 [new file with mode: 0644]
include/gomp-constants.h
libgomp/allocator.c
libgomp/libgomp.texi