gnu/gcc/d50e9f17fffa9b047dcf02eb9e1fe499178a0f02 openmp: Add GOMP_reduction_start and GOMP_reduction_end
When lowering reduction clauses, the compiler brackets the critical section
around the accumulation step with calls to GOMP_atomic_start and
GOMP_atomic_end. These are the same entry points used for `#pragma omp atomic'
constructs, so OMPT cannot distinguish reductions from user atomics.
Introduce dedicated GOMP_reduction_start and GOMP_reduction_end entry
points in libgomp. Update omp-low to emit calls to the new builtins
instead.
Also register the new builtins as memory barriers to avoid illegal optimisations
in later passes.
gcc/ChangeLog:
* omp-builtins.def (BUILT_IN_GOMP_REDUCTION_START): New builtin.
(BUILT_IN_GOMP_REDUCTION_END): New builtin.
* omp-low.cc (lower_reduction_clauses): Replace
BUILT_IN_GOMP_ATOMIC_START / BUILT_IN_GOMP_ATOMIC_END with
BUILT_IN_GOMP_REDUCTION_START / BUILT_IN_GOMP_REDUCTION_END.
(lower_omp_sections): Likewise.
(lower_omp_scope): Likewise.
(lower_omp_for): Likewise.
* tree-ssa-alias.cc (check_fnspec): Handle
BUILT_IN_GOMP_REDUCTION_START and BUILT_IN_GOMP_REDUCTION_END as
memory barriers.
libgomp/ChangeLog:
* atomic.c (GOMP_reduction_start): New function.
(GOMP_reduction_end): New function.
* libgomp.map (GOMP_6.0.2): Export GOMP_reduction_start and
GOMP_reduction_end.
* libgomp_g.h (GOMP_reduction_start): New declaration.
(GOMP_reduction_end): New declaration.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/atomic-builtins-1.c: New test.
* c-c++-common/gomp/reduction-builtins-1.c: New test.
8 files changed