diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1971,10 +1971,9 @@ } // TODO: NoUnwind attribute should be added for other GPU modes HIP, - // SYCL, OpenMP offload. AFAIK, none of them support exceptions in device - // code. + // OpenMP offload. AFAIK, neither of them support exceptions in device code. if ((getLangOpts().CUDA && getLangOpts().CUDAIsDevice) || - getLangOpts().OpenCL) { + getLangOpts().OpenCL || getLangOpts().SYCLIsDevice) { FuncAttrs.addAttribute(llvm::Attribute::NoUnwind); } diff --git a/clang/test/CodeGenSYCL/convergent.cpp b/clang/test/CodeGenSYCL/function-attrs.cpp rename from clang/test/CodeGenSYCL/convergent.cpp rename to clang/test/CodeGenSYCL/function-attrs.cpp --- a/clang/test/CodeGenSYCL/convergent.cpp +++ b/clang/test/CodeGenSYCL/function-attrs.cpp @@ -1,11 +1,18 @@ // RUN: %clang_cc1 -fsycl-is-device -emit-llvm -disable-llvm-passes \ -// RUN: -triple spir64 -emit-llvm %s -o - | FileCheck %s +// RUN: -triple spir64 -fexceptions -emit-llvm %s -o - | FileCheck %s -// CHECK-DAG: Function Attrs: -// CHECK-DAG-SAME: convergent -// CHECK-DAG-NEXT: define void @_Z3foov -void foo() { - int a = 1; +int foo(); + +// CHECK: define dso_local spir_func void @_Z3barv() [[BAR:#[0-9]+]] +// CHECK: attributes [[BAR]] = +// CHECK-SAME: convergent +// CHECK-SAME: nounwind +void bar() { + int a = foo(); +} + +int foo() { + return 1; } template