1 // RUN
: %clang_cc1 %s -cl-std
=CL1.2 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s
2 // RUN
: %clang_cc1 %s -cl-std
=CL1.2 -emit-llvm -triple amdgcn-unknown-unknown -o - | FileCheck -check-prefixes
=AMDGCN %s
3 // Test that the kernels always use the SPIR calling convention
4 // to have unambiguous mapping of arguments to feasibly implement
7 typedef struct int_single
{
11 typedef struct int_pair
{
16 typedef struct test_struct
{
27 kernel void test_single
(int_single input
, global int
* output
) {
29 // AMDGCN
: define
{{.
*}} amdgpu_kernel void
@test_single
30 // CHECK
: ptr nocapture
{{.
*}} byval
(%struct.int_single
)
31 // CHECK
: ptr nocapture noundef writeonly align
4 %output
35 kernel void test_pair(int_pair input, global int* output) {
37 // AMDGCN: define{{.*}} amdgpu_kernel void @test_pair
38 // CHECK: ptr nocapture {{.*}} byval(%struct.int_pair)
39 // CHECK: ptr nocapture noundef writeonly align 4 %output
40 output[0] = (int)input.a
;
41 output
[1] = (int)input.b;
44 kernel void test_kernel(test_struct input, global int* output) {
46 // AMDGCN: define{{.*}} amdgpu_kernel void @test_kernel
47 // CHECK: ptr nocapture {{.*}} byval(%struct.test_struct)
48 // CHECK: ptr nocapture noundef writeonly align 4 %output
49 output[0] = input.elementA;
50 output[1] = input.elementB
;
51 output
[2] = (int)input.elementC;
52 output[3] = (int)input.elementD;
53 output[4] = (int)input.elementE;
54 output[5] = (int)input.elementF;
55 output[6] = (int)input.elementG;
56 output[7] = (int)input.elementH;
59 void test_function(int_pair input, global int* output) {
60 // CHECK-NOT: spir_kernel
61 // AMDGCN-NOT: define{{.*}} amdgpu_kernel void @test_function
62 // CHECK: i64 %input.coerce0, i64 %input.coerce1, ptr nocapture noundef writeonly %output
63 output[0] = (int)input.a;
64 output[1] = (int)input.b;