t = fold_convert (itype, t);
n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true, GSI_SAME_STMT);
+ /* When GOMP_loop_end (or one of its variants) is emitted (e.g. with the
+ inscan modifier), which already implies the end of the scope, _start
+ variants of GOMP builtin calls have to be used and _end can be skipped. */
+ bool has_gomp_loop_end = fd->have_reductemp
+ || ((fd->have_pointer_condtemp || fd->have_scantemp)
+ && !fd->have_nonctrl_scantemp);
{
/* Fetch the thread/team id and the number of threads/teams in a single
call to GOMP_loop_static_worksharing or
{
case GF_OMP_FOR_KIND_FOR:
decl = builtin_decl_explicit (
- flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
- : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
+ flag_openmp_ompt || has_gomp_loop_end
+ ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
+ : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
break;
case GF_OMP_FOR_KIND_DISTRIBUTE:
decl = builtin_decl_explicit (
- flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
- : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
+ flag_openmp_ompt || has_gomp_loop_end
+ ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
+ : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
break;
default:
gcc_unreachable ();
}
gsi = gsi_last_nondebug_bb (exit_bb);
- if (flag_openmp_ompt)
+ if (flag_openmp_ompt && !has_gomp_loop_end)
{
/* Insert call to GOMP_*_static_worksharing_end at the end of exit_bb.
*/
n = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
true, GSI_SAME_STMT);
+ /* When GOMP_loop_end (or one of its variants) is emitted (e.g. with the
+ inscan modifier), which already implies the end of the scope, _start
+ variants of GOMP builtin calls have to be used and _end can be skipped. */
+ bool has_gomp_loop_end = fd->have_reductemp || fd->have_pointer_condtemp;
{
/* Fetch the thread/team id and the number of threads/teams in a single
call to GOMP_loop_static_worksharing or
{
case GF_OMP_FOR_KIND_FOR:
decl = builtin_decl_explicit (
- flag_openmp_ompt ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
- : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
+ flag_openmp_ompt || has_gomp_loop_end
+ ? BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING_START
+ : BUILT_IN_GOMP_LOOP_STATIC_WORKSHARING);
break;
case GF_OMP_FOR_KIND_DISTRIBUTE:
decl = builtin_decl_explicit (
- flag_openmp_ompt ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
- : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
+ flag_openmp_ompt || has_gomp_loop_end
+ ? BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING_START
+ : BUILT_IN_GOMP_DISTRIBUTE_STATIC_WORKSHARING);
break;
default:
gcc_unreachable ();
}
gsi = gsi_last_nondebug_bb (exit_bb);
- if (flag_openmp_ompt)
+ if (flag_openmp_ompt && !has_gomp_loop_end)
{
/* Insert call to GOMP_*_static_worksharing_end at the end of exit_bb.
*/
return nthreads + tid * 1I;
}
-/* OMPT variant enabled by -fopenmp-ompt. */
+/* OMPT variant enabled by -fopenmp-ompt and when GOMP_loop_end is called
+ (e.g. with the inscan modifier). */
_Complex int
GOMP_loop_static_worksharing_start (unsigned long long niter
__attribute__ ((unused)))
{}
-/* Stub for OMPT callback enabled by -fopenmp-ompt. */
+/* Stub for OMPT callback enabled by -fopenmp-ompt, except when GOMP_loop_end is
+ already called (e.g. with the inscan modifier). */
void
GOMP_loop_static_worksharing_end (void)