Skip to content

Commit 9565308

Browse files
elizabethandrewsFznamznon
authored andcommitted
Add builtin test with templates
1 parent adcef73 commit 9565308

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

clang/test/CodeGenSYCL/builtin-sycl-kernel-name.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class kernel_name_2;
88
typedef kernel_name_2 kernel_name_TD;
99
class kernel_name_3;
1010
class kernel_name_4;
11+
class kernel_name_5;
1112
typedef kernel_name_4 kernel_name_TD2;
1213

1314
struct constexpr_kernel_name;
@@ -32,6 +33,14 @@ struct SYCLKernel {
3233
void operator()() const {}
3334
};
3435

36+
template<typename KernelName>
37+
void test_template() {
38+
SYCLKernel Obj;
39+
kernel_single_task<KernelName>(Obj);
40+
const char* test6 = __builtin_sycl_kernel_name(kernel_id_t<KernelName>());
41+
constexpr const char* test7 = __builtin_sycl_kernel_name(kernel_id_t<KernelName>());
42+
}
43+
3544
void test() {
3645
SYCLKernel Obj;
3746
kernel_single_task<kernel_name_1>(Obj);
@@ -44,6 +53,7 @@ void test() {
4453
const char* test3 = __builtin_sycl_kernel_name(kernel_id_nt());
4554
const char* test4 = __builtin_sycl_kernel_name(kernel_id_t<kernel_name_4>());
4655
constexpr const char* test5 = __builtin_sycl_kernel_name(kernel_id_t<constexpr_kernel_name>());
56+
test_template<kernel_name_5>();
4757
}
4858

4959
// Kernel names retrieved from KernelInfo map
@@ -52,6 +62,7 @@ void test() {
5262
// CHECK: @2 = private unnamed_addr constant [44 x i8] c"_Z20__sycl_kernel_callerI13kernel_name_3Evv\00", align 1
5363
// CHECK: @3 = private unnamed_addr constant [44 x i8] c"_Z20__sycl_kernel_callerI13kernel_name_4Evv\00", align 1
5464
// CHECK: @.str = private unnamed_addr constant [52 x i8] c"_Z20__sycl_kernel_callerI21constexpr_kernel_nameEvv\00", align 1
65+
// CHECK: @4 = private unnamed_addr constant [44 x i8] c"_Z20__sycl_kernel_callerI13kernel_name_5Evv\00", align 1
5566

5667
// CHECK: define dso_local void @_Z4testv()
5768
// CHECK: %test1 = alloca ptr, align 8
@@ -65,3 +76,8 @@ void test() {
6576
// CHECK: store ptr @3, ptr %test4, align 8
6677
// CHECK: store ptr @.str, ptr %test5, align 8
6778

79+
// CHECK: define linkonce_odr void @_Z13test_templateI13kernel_name_5Evv()
80+
// CHECK: %test6 = alloca ptr, align 8
81+
// CHECK: %test7 = alloca ptr, align 8
82+
// CHECK: store ptr @4, ptr %test6, align 8
83+
// CHECK: store ptr @4, ptr %test7, align 8

0 commit comments

Comments
 (0)