openmp: Add barrier kind to GOMP_barrier and GOMP_barrier_cancel

GOMP_barrier is called for at least three distinct purposes: implicit
barriers at the end of parallel/teams regions, implicit barriers at the
end of worksharing constructs, and explicit `#pragma omp barrier'
directives. OMPT requires distinguishing these in its sync-region
callbacks.

Create new, semantically equivalent functions GOMP_barrier_ext and
GOMP_barrier_cancel_ext with an integer `kind' parameter. Update all compiler
call sites to pass the appropriate constant. Preserve now unused functions
GOMP_barrier and GOMP_barrier_cancel for backward compatibility.

The `kind' parameter is accepted but not yet acted upon in libgomp; it
is reserved for future OMPT instrumentation.

gcc/c-family/ChangeLog:

	* c-omp.cc (c_finish_omp_barrier): Pass GOMP_BARRIER_EXPLICIT to
	GOMP_barrier_ext.

gcc/cp/ChangeLog:

	* semantics.cc (finish_omp_barrier): Push GOMP_BARRIER_EXPLICIT
	onto the argument vector.

gcc/fortran/ChangeLog:

	* trans-openmp.cc (gfc_trans_omp_barrier): Pass GOMP_BARRIER_EXPLICIT
	to GOMP_barrier_ext.

gcc/ChangeLog:

	* omp-builtins.def (BUILT_IN_GOMP_BARRIER): Change function to
	GOMP_barrier_ext and type to BT_FN_VOID_INT.
	(BUILT_IN_GOMP_BARRIER_CANCEL): Change function to
	GOMP_barrier_cancel_ext and type to BT_FN_VOID_INT.
	* omp-expand.cc (expand_omp_for_static_nochunk): Pass
	GOMP_BARRIER_IMPLICIT_WORKSHARE to omp_build_barrier.
	(expand_omp_for_static_chunk): Likewise.
	(expand_omp_single): Likewise.
	* omp-general.cc (omp_build_barrier): Add kind parameter; pass it
	to GOMP_barrier_ext or GOMP_barrier_cancel_ext.
	* omp-general.h (omp_build_barrier): Update declaration to add
	kind parameter.
	* omp-low.cc (lower_rec_input_clauses): Determine barrier kind from
	the enclosing gimple statement code and pass it to omp_build_barrier.
	(lower_omp_for_scan): Pass GOMP_BARRIER_IMPLICIT_WORKSHARE to
	omp_build_barrier.

include/ChangeLog:

	* gomp-constants.h (GOMP_BARRIER_IMPLICIT_PARALLEL): New macro.
	(GOMP_BARRIER_IMPLICIT_WORKSHARE): New macro.
	(GOMP_BARRIER_EXPLICIT): New macro.

libgomp/ChangeLog:

	* barrier.c (GOMP_barrier_ext): New function.
	(GOMP_barrier_cancel_ext): Likewise.
	* libgomp_g.h (GOMP_barrier_ext): Declare.
	(GOMP_barrier_cancel_ext): Likewise.
	* libgomp.map (GOMP_6.0.2): Add GOMP_barrier_ext and
	GOMP_barrier_cancel_ext.
	* testsuite/libgomp.c/barrier-1.c: Update GOMP_barrier_ext calls to pass
	GOMP_BARRIER_EXPLICIT.

gcc/testsuite/ChangeLog:

	* g++.dg/gomp/barrier-1.C: Update scan dump.
	* g++.dg/gomp/tpl-barrier-1.C: Likewise.
	* gcc.dg/gomp/barrier-1.c: Likewise.
	* c-c++-common/gomp/implicit-barrier-1.c: New test.
	* gfortran.dg/gomp/lastprivate-allocatable-barrier-1.f90: New test.
18 files changed