|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device %s -emit-llvm -triple spir64-unknown-unknown -o - | FileCheck %s |
| 2 | + |
| 3 | +struct __attribute__((sycl_special_class)) |
| 4 | + [[__sycl_detail__::sycl_type(annotated_arg)]] |
| 5 | + AnnotatedIntPtr { |
| 6 | + void __init([[__sycl_detail__::add_ir_attributes_kernel_parameter( |
| 7 | + "sycl-restrict", nullptr)]] |
| 8 | + __attribute__((opencl_global)) int* InPtr) { |
| 9 | + Ptr = InPtr; |
| 10 | + } |
| 11 | + |
| 12 | + int &operator[](unsigned I) const { return Ptr[I]; } |
| 13 | + |
| 14 | + __attribute__((opencl_global)) int *Ptr; |
| 15 | +}; |
| 16 | + |
| 17 | +template <typename name, typename Func> |
| 18 | +__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) { |
| 19 | + kernelFunc(); |
| 20 | +} |
| 21 | + |
| 22 | +int main() { |
| 23 | + { |
| 24 | + int *a; |
| 25 | + int *b; |
| 26 | + int *c; |
| 27 | + kernel<class kernel_norestrict>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 28 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_norestrict(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}) |
| 29 | + } |
| 30 | + { |
| 31 | + AnnotatedIntPtr a; |
| 32 | + int *b; |
| 33 | + int *c; |
| 34 | + kernel<class kernel_restrict1>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 35 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict1(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}) |
| 36 | + } |
| 37 | + { |
| 38 | + int *a; |
| 39 | + AnnotatedIntPtr b; |
| 40 | + int *c; |
| 41 | + kernel<class kernel_restrict2>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 42 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict2(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}) |
| 43 | + } |
| 44 | + { |
| 45 | + int *a; |
| 46 | + int *b; |
| 47 | + AnnotatedIntPtr c; |
| 48 | + kernel<class kernel_restrict3>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 49 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict3(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}) |
| 50 | + } |
| 51 | + { |
| 52 | + AnnotatedIntPtr a; |
| 53 | + AnnotatedIntPtr b; |
| 54 | + int *c; |
| 55 | + kernel<class kernel_restrict4>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 56 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict4(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}) |
| 57 | + } |
| 58 | + { |
| 59 | + AnnotatedIntPtr a; |
| 60 | + int *b; |
| 61 | + AnnotatedIntPtr c; |
| 62 | + kernel<class kernel_restrict5>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 63 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict5(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}) |
| 64 | + } |
| 65 | + { |
| 66 | + int *a; |
| 67 | + AnnotatedIntPtr b; |
| 68 | + AnnotatedIntPtr c; |
| 69 | + kernel<class kernel_restrict6>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 70 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict6(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}) |
| 71 | + } |
| 72 | + { |
| 73 | + AnnotatedIntPtr a; |
| 74 | + AnnotatedIntPtr b; |
| 75 | + AnnotatedIntPtr c; |
| 76 | + kernel<class kernel_restrict7>([a, b, c]() { c[0] = a[0] + b[0]; }); |
| 77 | + // CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict7(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}) |
| 78 | + } |
| 79 | +} |
0 commit comments