diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2882,7 +2882,8 @@ 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, diff --git a/clang/test/CodeGenSYCL/convergent.cpp b/clang/test/CodeGenSYCL/convergent.cpp new file mode 100644 --- /dev/null +++ b/clang/test/CodeGenSYCL/convergent.cpp @@ -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 +__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) { + kernelFunc(); +} + +int main() { + kernel_single_task([] { foo(); }); + return 0; +}