Author: Alexey Bader Date: 2020-09-29T15:23:50+03:00 New Revision: 9263931fcccdc99000c1de668bea330711333729
URL: https://github.com/llvm/llvm-project/commit/9263931fcccdc99000c1de668bea330711333729 DIFF: https://github.com/llvm/llvm-project/commit/9263931fcccdc99000c1de668bea330711333729.diff LOG: [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 Added: clang/test/CodeGenSYCL/convergent.cpp Modified: clang/lib/Frontend/CompilerInvocation.cpp Removed: ################################################################################ diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 2d008d8a3fbe..42224339250d 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -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, diff --git a/clang/test/CodeGenSYCL/convergent.cpp b/clang/test/CodeGenSYCL/convergent.cpp new file mode 100644 index 000000000000..784fb8976c27 --- /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 <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; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits