Skip to content

Commit ffd8794

Browse files
authored
Revert "[SYCL] Disallow mutable lambdas (#1785)"
This reverts commit a43dcc2.
1 parent c6c2ecd commit ffd8794

File tree

134 files changed

+404
-453
lines changed

Some content is hidden

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

134 files changed

+404
-453
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,7 @@ def OpenMP : DiagGroup<"openmp", [
11271127
]>;
11281128

11291129
// SYCL warnings
1130-
def Sycl2017Compat : DiagGroup<"sycl-2017-compat">;
1131-
def Sycl2020Compat : DiagGroup<"sycl-2020-compat">;
1132-
def SyclStrict : DiagGroup<"sycl-strict", [ Sycl2017Compat, Sycl2020Compat]>;
1130+
def SyclStrict : DiagGroup<"sycl-strict">;
11331131
def SyclTarget : DiagGroup<"sycl-target">;
11341132

11351133
// Backend warnings.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10974,12 +10974,6 @@ def warn_boolean_attribute_argument_is_not_valid: Warning<
1097410974
def err_sycl_attibute_cannot_be_applied_here
1097510975
: Error<"%0 attribute cannot be applied to a "
1097610976
"static function or function in an anonymous namespace">;
10977-
def warn_sycl_pass_by_value_deprecated
10978-
: Warning<"Passing kernel functions by value is deprecated in SYCL 2020">,
10979-
InGroup<Sycl2020Compat>;
10980-
def warn_sycl_pass_by_reference_future
10981-
: Warning<"Passing of kernel functions by reference is a SYCL 2020 extension">,
10982-
InGroup<Sycl2017Compat>;
1098310977
def warn_sycl_attibute_function_raw_ptr
1098410978
: Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied "
1098510979
"to a function with a raw pointer "

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
25872587
if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
25882588
Opts.SYCLVersion = llvm::StringSwitch<unsigned>(A->getValue())
25892589
.Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017)
2590-
.Case("2020", 2020)
25912590
.Default(0U);
25922591

25932592
if (Opts.SYCLVersion == 0U) {

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -698,38 +698,7 @@ getKernelInvocationKind(FunctionDecl *KernelCallerFunc) {
698698
}
699699

700700
static const CXXRecordDecl *getKernelObjectType(FunctionDecl *Caller) {
701-
QualType KernelParamTy = (*Caller->param_begin())->getType();
702-
// In SYCL 2020 kernels are now passed by reference.
703-
if (KernelParamTy->isReferenceType())
704-
return KernelParamTy->getPointeeCXXRecordDecl();
705-
706-
// SYCL 1.2.1
707-
return KernelParamTy->getAsCXXRecordDecl();
708-
}
709-
710-
static void checkKernelAndCaller(Sema &SemaRef, FunctionDecl *Caller,
711-
const CXXRecordDecl *KernelObj) {
712-
// check captures
713-
if (KernelObj->isLambda()) {
714-
for (const LambdaCapture &LC : KernelObj->captures())
715-
if (LC.capturesThis() && LC.isImplicit())
716-
SemaRef.Diag(LC.getLocation(), diag::err_implicit_this_capture);
717-
}
718-
719-
// check that calling kernel conforms to spec
720-
assert(Caller->param_size() >= 1 && "missing kernel function argument.");
721-
QualType KernelParamTy = (*Caller->param_begin())->getType();
722-
if (KernelParamTy->isReferenceType()) {
723-
// passing by reference, so emit warning if not using SYCL 2020
724-
if (SemaRef.LangOpts.SYCLVersion < 2020)
725-
SemaRef.Diag(Caller->getLocation(),
726-
diag::warn_sycl_pass_by_reference_future);
727-
} else {
728-
// passing by value. emit warning if using SYCL 2020 or greater
729-
if (SemaRef.LangOpts.SYCLVersion > 2017)
730-
SemaRef.Diag(Caller->getLocation(),
731-
diag::warn_sycl_pass_by_value_deprecated);
732-
}
701+
return (*Caller->param_begin())->getType()->getAsCXXRecordDecl();
733702
}
734703

735704
/// Creates a kernel parameter descriptor
@@ -1944,8 +1913,11 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
19441913
constructKernelName(*this, KernelCallerFunc, MC);
19451914
StringRef KernelName(getLangOpts().SYCLUnnamedLambda ? StableName
19461915
: CalculatedName);
1947-
1948-
checkKernelAndCaller(*this, KernelCallerFunc, KernelObj);
1916+
if (KernelObj->isLambda()) {
1917+
for (const LambdaCapture &LC : KernelObj->captures())
1918+
if (LC.capturesThis() && LC.isImplicit())
1919+
Diag(LC.getLocation(), diag::err_implicit_this_capture);
1920+
}
19491921
SyclKernelFieldChecker checker(*this);
19501922
SyclKernelDeclCreator kernel_decl(
19511923
*this, checker, KernelName, KernelObj->getLocation(),

clang/test/CodeGenSYCL/Inputs/sycl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,26 @@ class spec_constant {
260260

261261
#define ATTR_SYCL_KERNEL __attribute__((sycl_kernel))
262262
template <typename KernelName = auto_name, typename KernelType>
263-
ATTR_SYCL_KERNEL void kernel_single_task(const KernelType &kernelFunc) {
263+
ATTR_SYCL_KERNEL void kernel_single_task(KernelType kernelFunc) {
264264
kernelFunc();
265265
}
266266

267267
template <typename KernelName, typename KernelType, int Dims>
268268
ATTR_SYCL_KERNEL void
269-
kernel_parallel_for(const KernelType &KernelFunc) {
269+
kernel_parallel_for(KernelType KernelFunc) {
270270
KernelFunc(id<Dims>());
271271
}
272272

273273
template <typename KernelName, typename KernelType, int Dims>
274274
ATTR_SYCL_KERNEL void
275-
kernel_parallel_for_work_group(const KernelType &KernelFunc) {
275+
kernel_parallel_for_work_group(KernelType KernelFunc) {
276276
KernelFunc(group<Dims>());
277277
}
278278

279279
class handler {
280280
public:
281281
template <typename KernelName = auto_name, typename KernelType, int Dims>
282-
void parallel_for(range<Dims> numWorkItems, const KernelType &kernelFunc) {
282+
void parallel_for(range<Dims> numWorkItems, KernelType kernelFunc) {
283283
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
284284
#ifdef __SYCL_DEVICE_ONLY__
285285
kernel_parallel_for<NameT, KernelType, Dims>(kernelFunc);
@@ -289,7 +289,7 @@ class handler {
289289
}
290290

291291
template <typename KernelName = auto_name, typename KernelType, int Dims>
292-
void parallel_for_work_group(range<Dims> numWorkGroups, range<Dims> WorkGroupSize, const KernelType &kernelFunc) {
292+
void parallel_for_work_group(range<Dims> numWorkGroups, range<Dims> WorkGroupSize, KernelType kernelFunc) {
293293
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
294294
#ifdef __SYCL_DEVICE_ONLY__
295295
kernel_parallel_for_work_group<NameT, KernelType, Dims>(kernelFunc);
@@ -300,7 +300,7 @@ class handler {
300300
}
301301

302302
template <typename KernelName = auto_name, typename KernelType>
303-
void single_task(const KernelType &kernelFunc) {
303+
void single_task(KernelType kernelFunc) {
304304
using NameT = typename get_kernel_name_t<KernelName, KernelType>::name;
305305
#ifdef __SYCL_DEVICE_ONLY__
306306
kernel_single_task<NameT>(kernelFunc);

clang/test/CodeGenSYCL/address-space-cond-op.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ S foo(bool cond, S &lhs, S rhs) {
2424
}
2525

2626
template <typename name, typename Func>
27-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
27+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
2828
kernelFunc();
2929
}
3030

clang/test/CodeGenSYCL/address-space-new.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ void test() {
110110
// CHECK: call spir_func void @{{.*}}bar{{.*}}(%struct.{{.*}}.HasX addrspace(4)* align 4 dereferenceable(4) %[[SECOND]])
111111
}
112112

113+
113114
template <typename name, typename Func>
114-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
115+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
115116
kernelFunc();
116117
}
117118

119+
118120
int main() {
119121
kernel_single_task<class fake_kernel>([]() { test(); });
120122
return 0;

clang/test/CodeGenSYCL/address-space-of-returns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A ret_agg() {
2929
// CHECK: define spir_func void @{{.*}}ret_agg{{.*}}(%struct.{{.*}}.A addrspace(4)* {{.*}} %agg.result)
3030

3131
template <typename name, typename Func>
32-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
32+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
3333
kernelFunc();
3434
}
3535

clang/test/CodeGenSYCL/address-space-parameter-conversions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void usages2() {
195195
}
196196

197197
template <typename name, typename Func>
198-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
198+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
199199
kernelFunc();
200200
}
201201
int main() {

clang/test/CodeGenSYCL/basic-kernel-wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "sycl.hpp"
77

88
template <typename name, typename Func>
9-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
9+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
1010
kernelFunc();
1111
}
1212

clang/test/CodeGenSYCL/const-wg-init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
template <typename KernelName, typename KernelType>
66
__attribute__((sycl_kernel)) void
7-
kernel_parallel_for_work_group(const KernelType &KernelFunc) {
7+
kernel_parallel_for_work_group(KernelType KernelFunc) {
88
cl::sycl::group<1> G;
99
KernelFunc(G);
1010
}

clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <sycl.hpp>
1212

1313
template <typename name, typename Func>
14-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
14+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
1515
kernelFunc();
1616
}
1717

clang/test/CodeGenSYCL/device-functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ T bar(T arg) {
1313
}
1414

1515
template <typename name, typename Func>
16-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
16+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
1717
kernelFunc();
1818
}
1919

clang/test/CodeGenSYCL/device-variables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static constexpr int my_array[1] = {42};
1111
void foo(const test_type &) {}
1212

1313
template <typename name, typename Func>
14-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
14+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
1515
kernelFunc();
1616
}
1717

clang/test/CodeGenSYCL/emit-kernel-in-virtual-func.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
22

33
template <typename name, typename Func>
4-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
4+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
55
kernelFunc();
66
}
77

clang/test/CodeGenSYCL/emit-kernel-in-virtual-func2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | FileCheck %s
22

33
template <typename name, typename Func>
4-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
5-
kernelFunc();
4+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
5+
kernelFunc();
66
}
77

88
template <class TAR>

clang/test/CodeGenSYCL/esimd_metadata1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// 3. Proper module !spirv.Source metadata is generated
1010

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

clang/test/CodeGenSYCL/fpga_pipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class pipe {
4545
};
4646

4747
template <typename name, typename Func>
48-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
48+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
4949
kernelFunc();
5050
}
5151

clang/test/CodeGenSYCL/inheritance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct base {
2424
struct derived : base, second_base {
2525
int a;
2626

27-
void operator()() const {
27+
void operator()() {
2828
}
2929
};
3030

clang/test/CodeGenSYCL/inline_asm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class kernel;
44

55
template <typename name, typename Func>
6-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
6+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
77
// CHECK: %[[ARRAY_A:[0-9a-z]+]] = alloca [100 x i32], align 4
88
// CHECK: %[[IDX:.*]] = getelementptr inbounds [100 x i32], [100 x i32]* %[[ARRAY_A]], i64 0, i64 0
99
int a[100], i = 0;

clang/test/CodeGenSYCL/inlining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice %s -S -emit-llvm -o - | FileCheck %s
22

33
template <typename name, typename Func>
4-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
4+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
55
kernelFunc();
66
}
77

clang/test/CodeGenSYCL/int_header1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "sycl.hpp"
2323

2424
template <typename KernelName, typename KernelType>
25-
__attribute__((sycl_kernel)) void kernel_single_task(const KernelType &kernelFunc) {
25+
__attribute__((sycl_kernel)) void kernel_single_task(KernelType kernelFunc) {
2626
kernelFunc();
2727
}
2828

clang/test/CodeGenSYCL/int_header_inline_ns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "sycl.hpp"
99

1010
template <typename KernelName, typename KernelType>
11-
__attribute__((sycl_kernel)) void kernel_single_task(const KernelType &kernelFunc) {
11+
__attribute__((sycl_kernel)) void kernel_single_task(KernelType kernelFunc) {
1212
kernelFunc();
1313
}
1414

clang/test/CodeGenSYCL/integration_header.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#include "sycl.hpp"
6969

7070
template <typename KernelName, typename KernelType>
71-
__attribute__((sycl_kernel)) void kernel_single_task(const KernelType &kernelFunc) {
71+
__attribute__((sycl_kernel)) void kernel_single_task(KernelType kernelFunc) {
7272
kernelFunc();
7373
}
7474
struct x {};

clang/test/CodeGenSYCL/intel-fpga-ivdep-array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void ivdep_struct() {
178178
}
179179

180180
template <typename name, typename Func>
181-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
181+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
182182
kernelFunc();
183183
}
184184

clang/test/CodeGenSYCL/intel-fpga-ivdep-embedded-loops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void ivdep_embedded_multiple_dimensions() {
148148
}
149149

150150
template <typename name, typename Func>
151-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
151+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
152152
kernelFunc();
153153
}
154154

clang/test/CodeGenSYCL/intel-fpga-ivdep-global.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void ivdep_conflicting_safelen() {
8080
}
8181

8282
template <typename name, typename Func>
83-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
83+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
8484
kernelFunc();
8585
}
8686

clang/test/CodeGenSYCL/intel-fpga-local.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void field_addrspace_cast() {
256256
}
257257

258258
template <typename name, typename Func>
259-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
259+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
260260
kernelFunc();
261261
}
262262

clang/test/CodeGenSYCL/intel-fpga-loops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void speculated_iterations() {
9595
}
9696

9797
template <typename name, typename Func>
98-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
98+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
9999
kernelFunc();
100100
}
101101

clang/test/CodeGenSYCL/intel-fpga-mem-builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void foo(float *A, int *B, State *C, State &D) {
7171
// CHECK-DAG: attributes [[ATT]] = { readnone }
7272

7373
template <typename name, typename Func>
74-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
74+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
7575
kernelFunc();
7676
}
7777

clang/test/CodeGenSYCL/intel-fpga-no-global-work-offset.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
class Foo {
44
public:
5-
[[intelfpga::no_global_work_offset(1)]] void operator()() const {}
5+
[[intelfpga::no_global_work_offset(1)]] void operator()() {}
66
};
77

88
template <typename name, typename Func>
9-
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
9+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
1010
kernelFunc();
1111
}
1212

clang/test/CodeGenSYCL/intel-fpga-reg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void foo() {
143143
}
144144

145145
template <typename name, typename Func>
146-
__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
146+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
147147
kernelFunc();
148148
}
149149

0 commit comments

Comments
 (0)