Skip to content

Commit 1c5c2a4

Browse files
committed
Make error and fix test arguments
Signed-off-by: Larsen, Steffen <[email protected]>
1 parent af03188 commit 1c5c2a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+116
-177
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12519,9 +12519,8 @@ def err_sycl_num_kernel_wrong_reqd_wg_size : Error<
1251912519
def err_sycl_invalid_aspect_argument : Error<
1252012520
"%0 attribute argument is invalid; argument must be device aspect of type sycl::aspect">;
1252112521

12522-
def warn_sycl_pass_by_value_deprecated
12523-
: Warning<"passing kernel functions by value is deprecated in SYCL 2020">,
12524-
InGroup<Sycl2020Compat>, ShowInSystemHeader;
12522+
def err_sycl_kernel_pass_by_value
12523+
: Error<"SYCL kernel function must be passed by reference">;
1252512524
def warn_sycl_potentially_invalid_as_cast : Warning<
1252612525
"explicit cast from %0 to %1 potentially leads to an invalid address space"
1252712526
" cast in the resulting code">, InGroup<SyclStrict>,

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ static QualType GetSYCLKernelObjectType(const FunctionDecl *KernelCaller) {
11271127
assert(KernelCaller->getNumParams() > 0 && "Insufficient kernel parameters");
11281128
QualType KernelParamTy = KernelCaller->getParamDecl(0)->getType();
11291129

1130-
// SYCL 2020 kernels are passed by reference.
1131-
assert(KernelParamTy->isReferenceType() && "Since SYCL 2020 kernels must be passed by reference.");
1130+
assert(KernelParamTy->isReferenceType() &&
1131+
"Kernel function must be passed by reference.");
11321132
return KernelParamTy = KernelParamTy->getPointeeType();
11331133
}
11341134

@@ -5032,13 +5032,9 @@ void SemaSYCL::CheckSYCLKernelCall(FunctionDecl *KernelFunc,
50325032
}
50335033
}
50345034

5035-
// check that calling kernel conforms to spec
5036-
QualType KernelParamTy = KernelFunc->getParamDecl(0)->getType();
5037-
if (! KernelParamTy->isReferenceType()) {
5038-
// passing by value. emit warning if using SYCL 2020 or greater
5039-
if (SemaRef.LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020)
5040-
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_value_deprecated);
5041-
}
5035+
// SYCL only supports passing kernel functions by reference.
5036+
if (!KernelFunc->getParamDecl(0)->getType()->isReferenceType())
5037+
Diag(KernelFunc->getLocation(), diag::err_sycl_kernel_pass_by_value);
50425038

50435039
// Do not visit invalid kernel object.
50445040
if (KernelObj->isInvalidDecl())
@@ -5163,8 +5159,8 @@ void SemaSYCL::SetSYCLKernelNames() {
51635159
//
51645160
// Example of kernel caller function:
51655161
// template <typename KernelName, typename KernelType/*, ...*/>
5166-
// __attribute__((sycl_kernel)) void kernel_caller_function(KernelType
5167-
// KernelFuncObj) {
5162+
// __attribute__((sycl_kernel))
5163+
// void kernel_caller_function(const KernelType &KernelFuncObj) {
51685164
// KernelFuncObj();
51695165
// }
51705166
//

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,6 @@ ATTR_SYCL_KERNEL void kernel_single_task(const KernelType &kernelFunc, kernel_ha
542542
kernelFunc(kh);
543543
}
544544

545-
template <typename KernelName, typename KernelType>
546-
ATTR_SYCL_KERNEL void kernel_single_task_2017(KernelType kernelFunc) { // #KernelSingleTask2017
547-
kernelFunc();
548-
}
549-
550545
template <typename KernelName, typename KernelType, int Dims>
551546
ATTR_SYCL_KERNEL void
552547
kernel_parallel_for(const KernelType &KernelFunc) {
@@ -608,16 +603,6 @@ class handler {
608603
kernel_single_task<NameT>(kernelFunc, kh);
609604
#else
610605
kernelFunc(kh);
611-
#endif
612-
}
613-
614-
template <typename KernelName = auto_name, typename KernelType>
615-
void single_task_2017(KernelType kernelFunc) {
616-
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
617-
#ifdef __SYCL_DEVICE_ONLY__
618-
kernel_single_task_2017<NameT>(kernelFunc);
619-
#else
620-
kernelFunc();
621606
#endif
622607
}
623608
};

clang/test/CodeGenSYCL/esimd-private-global.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ __attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) __attribute_
77
// CHECK: @vc = {{.+}} i32 0, align 4 #[[ATTR:[0-9]+]]
88

99
template <typename name, typename Func>
10-
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
10+
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
1111
kernelFunc();
1212
}
1313

clang/test/CodeGenSYCL/esimd_metadata2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ESIMDFunctor {
2020
};
2121

2222
template <typename name, typename Func>
23-
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
23+
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
2424
kernelFunc();
2525
}
2626

clang/test/CodeGenSYCL/union-kernel-param-ih.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ union MyUnion {
3535
};
3636

3737
template <typename name, typename Func>
38-
__attribute__((sycl_kernel)) void a_kernel(Func kernelFunc) {
38+
__attribute__((sycl_kernel)) void a_kernel(const Func &kernelFunc) {
3939
kernelFunc();
4040
}
4141

clang/test/CodeGenSYCL/union-kernel-param.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ union MyUnion {
99
};
1010

1111
template <typename name, typename Func>
12-
__attribute__((sycl_kernel)) void a_kernel(Func kernelFunc) {
12+
__attribute__((sycl_kernel)) void a_kernel(const Func &kernelFunc) {
1313
kernelFunc();
1414
}
1515

clang/test/CodeGenSYCL/unique_stable_name.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ struct Derp {
6161
};
6262

6363
template <typename KernelName, typename KernelType>
64-
[[clang::sycl_kernel]] void kernel_single_task(KernelType kernelFunc) {
64+
[[clang::sycl_kernel]] void kernel_single_task(const KernelType &kernelFunc) {
6565
kernelFunc();
6666
}
6767

6868
template<typename KernelType>
69-
void unnamed_kernel_single_task(KernelType kernelFunc) {
69+
void unnamed_kernel_single_task(const KernelType &kernelFunc) {
7070
kernel_single_task<KernelType>(kernelFunc);
7171
}
7272

7373
template <typename KernelName, typename KernelType>
74-
void not_kernel_single_task(KernelType kernelFunc) {
74+
void not_kernel_single_task(const KernelType &kernelFunc) {
7575
kernelFunc();
7676
}
7777

clang/test/CodeGenSYCL/unique_stable_name_windows_diff.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33

44

55
template<typename KN, typename Func>
6-
__attribute__((sycl_kernel)) void kernel(Func F){
6+
__attribute__((sycl_kernel)) void kernel(const Func &F){
77
F();
88
}
99

1010
template<typename Func>
11-
void kernel_wrapper(Func F) {
11+
void kernel_wrapper(const Func &F) {
1212
kernel<Func>(F);
1313
}
1414

1515
template<typename KN, typename Func>
16-
__attribute__((sycl_kernel)) void kernel2(Func F){
16+
__attribute__((sycl_kernel)) void kernel2(const Func &F){
1717
F(1);
1818
}
1919

2020
template<typename Func>
21-
void kernel2_wrapper(Func F) {
21+
void kernel2_wrapper(const Func &F) {
2222
kernel2<Func>(F);
2323
}
2424

2525
template<typename KN, typename Func>
26-
__attribute__((sycl_kernel)) void kernel3(Func F){
26+
__attribute__((sycl_kernel)) void kernel3(const Func &F){
2727
F(1.1);
2828
}
2929

3030
template<typename Func>
31-
void kernel3_wrapper(Func F) {
31+
void kernel3_wrapper(const Func &F) {
3232
kernel3<Func>(F);
3333
}
3434

clang/test/Frontend/Inputs/sycl.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,6 @@ ATTR_SYCL_KERNEL void kernel_single_task(const KernelType &kernelFunc, kernel_ha
400400
kernelFunc(kh);
401401
}
402402

403-
template <typename KernelName, typename KernelType>
404-
ATTR_SYCL_KERNEL void kernel_single_task_2017(KernelType kernelFunc) { // #KernelSingleTask2017
405-
kernelFunc();
406-
}
407-
408403
template <typename KernelName, typename KernelType, int Dims>
409404
ATTR_SYCL_KERNEL void
410405
kernel_parallel_for(const KernelType &KernelFunc) {
@@ -466,16 +461,6 @@ class handler {
466461
kernel_single_task<NameT>(kernelFunc, kh);
467462
#else
468463
kernelFunc(kh);
469-
#endif
470-
}
471-
472-
template <typename KernelName = auto_name, typename KernelType>
473-
void single_task_2017(KernelType kernelFunc) {
474-
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
475-
#ifdef __SYCL_DEVICE_ONLY__
476-
kernel_single_task_2017<NameT>(kernelFunc);
477-
#else
478-
kernelFunc();
479464
#endif
480465
}
481466
};

0 commit comments

Comments
 (0)