[SYCL] Assume SYCL device functions are convergent

SYCL device compiler (similar to other SPMD compilers) assumes that
functions are convergent by default to avoid invalid transformations.
This attribute can be removed if compiler can prove that function does
not have convergent operations.

Reviewed By: Naghasan

Differential Revision: https://reviews.llvm.org/D87282
This commit is contained in:
Alexey Bader 2020-08-25 17:05:19 +03:00
parent c5a4900e1a
commit 9263931fcc
2 changed files with 22 additions and 1 deletions

View File

@ -2882,7 +2882,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.Coroutines = Opts.CPlusPlus20 || Args.hasArg(OPT_fcoroutines_ts);
Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
Args.hasArg(OPT_fconvergent_functions);
Opts.SYCLIsDevice ||
Args.hasArg(OPT_fconvergent_functions);
Opts.DoubleSquareBracketAttributes =
Args.hasFlag(OPT_fdouble_square_bracket_attributes,

View File

@ -0,0 +1,20 @@
// RUN: %clang_cc1 -fsycl -fsycl-is-device -emit-llvm -disable-llvm-passes \
// RUN: -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | \
// RUN: FileCheck %s
// CHECK-DAG: Function Attrs:
// CHECK-DAG-SAME: convergent
// CHECK-DAG-NEXT: define void @_Z3foov
void foo() {
int a = 1;
}
template <typename Name, typename Func>
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
kernelFunc();
}
int main() {
kernel_single_task<class fake_kernel>([] { foo(); });
return 0;
}