summaryrefslogtreecommitdiff
path: root/gcc/c-family/c-omp.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2020-08-22 18:23:26 -0700
committerSandra Loosemore <sandra@codesourcery.com>2020-08-22 18:23:26 -0700
commit1c9af55d7ff76e2e6b633af33e6e6991a0ba4c48 (patch)
treea88cd7573a7a4db681b7af711199b0710d98f8fe /gcc/c-family/c-omp.c
parent8ec8095634cab5053da4c49935eeba13f2aee2fa (diff)
downloadgcc-1c9af55d7ff76e2e6b633af33e6e6991a0ba4c48.tar.gz
Permit calls to builtins and intrinsics in kernels loops.
This tweak to the OpenACC kernels loop annotation relaxes the restrictions on function calls in the loop body. Normally calls to functions not explicitly marked with a parallelism attribute are not permitted, but C/C++ builtins and Fortran intrinsics have known semantics so we can generally permit those without restriction. If any turn out to be problematical, we can add on here to recognize them, or in the processing of the "auto" annotations. 2020-08-22 Sandra Loosemore <sandra@codesourcery.com> gcc/c-family/ * c-omp.c (annotate_loops_in_kernels_regions): Test for calls to builtins. gcc/fortran/ * openmp.c (check_expr_for_invalid_calls): Check for intrinsic functions. gcc/testsuite/ * c-c++-common/goacc/kernels-loop-annotation-20.c: New. * gfortran.dg/goacc/kernels-loop-annotation-20.f95: New.
Diffstat (limited to 'gcc/c-family/c-omp.c')
-rw-r--r--gcc/c-family/c-omp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 24f2448b235..34523cee454 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -2850,8 +2850,9 @@ annotate_loops_in_kernels_regions (tree *nodeptr, int *walk_subtrees,
break;
case CALL_EXPR:
- /* Direct function calls to functions marked as OpenACC routines are
- allowed. Reject indirect calls or calls to non-routines. */
+ /* Direct function calls to builtins and functions marked as
+ OpenACC routines are allowed. Reject indirect calls or calls
+ to non-routines. */
if (info->state >= as_in_kernels_loop)
{
tree fn = CALL_EXPR_FN (node), fn_decl = NULL_TREE;
@@ -2865,8 +2866,9 @@ annotate_loops_in_kernels_regions (tree *nodeptr, int *walk_subtrees,
}
if (fn_decl == NULL_TREE)
do_not_annotate_loop_nest (info, as_invalid_call, node);
- else if (!lookup_attribute ("oacc function",
- DECL_ATTRIBUTES (fn_decl)))
+ else if (!fndecl_built_in_p (fn_decl, BUILT_IN_NORMAL)
+ && !lookup_attribute ("oacc function",
+ DECL_ATTRIBUTES (fn_decl)))
do_not_annotate_loop_nest (info, as_invalid_call, node);
}
break;