1 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes
=COMMON
,SPIR %s
2 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes
=COMMON
,AMDGCN %s
3 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -emit-llvm -o - -O0 -debug-info-kind
=limited -triple spir-unknown-unknown | FileCheck -check-prefixes
=CHECK-DEBUG %s
4 // RUN
: %clang_cc1 %s -cl-std
=CL2.0 -emit-llvm -o - -O0 -debug-info-kind
=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes
=CHECK-DEBUG %s
5 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -cl-ext
=-all
,+__opencl_c_device_enqueue
,+__opencl_c_generic_address_space
,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck -check-prefixes
=COMMON
,SPIR %s
6 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -cl-ext
=-all
,+__opencl_c_device_enqueue
,+__opencl_c_generic_address_space
,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes
=COMMON
,AMDGCN %s
7 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -cl-ext
=-all
,+__opencl_c_device_enqueue
,+__opencl_c_generic_address_space
,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -debug-info-kind
=limited -triple spir-unknown-unknown | FileCheck -check-prefixes
=CHECK-DEBUG %s
8 // RUN
: %clang_cc1 %s -cl-std
=CL3.0 -cl-ext
=-all
,+__opencl_c_device_enqueue
,+__opencl_c_generic_address_space
,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -debug-info-kind
=limited -triple amdgcn-amd-amdhsa | FileCheck -check-prefixes
=CHECK-DEBUG %s
10 // SPIR
: @__block_literal_global
= internal addrspace
(1) constant
{ i32
, i32
, ptr addrspace
(4) } { i32
12, i32
4, ptr addrspace
(4) addrspacecast
(ptr @block_A_block_invoke to ptr addrspace
(4)) }
11 // AMDGCN
: @__block_literal_global
= internal addrspace
(1) constant
{ i32
, i32
, ptr
} { i32
16, i32
8, ptr
@block_A_block_invoke
}
14 // SPIR-LABEL
: define internal
{{.
*}}void
@block_A_block_invoke
(ptr addrspace
(4) noundef %.block_descriptor
, ptr addrspace
(3) noundef %a
)
15 // AMDGCN-LABEL
: define internal
{{.
*}}void
@block_A_block_invoke
(ptr noundef %.block_descriptor
, ptr addrspace
(3) noundef %a
)
16 void
(^block_A
)(local void
*) = ^
(local void
*a
) {
20 // COMMON-LABEL
: define
{{.
*}}void
@foo
()
23 // COMMON-NOT
: %block.isa
24 // COMMON-NOT
: %block.flags
25 // COMMON-NOT
: %block.reserved
26 // COMMON-NOT
: %block.descriptor
27 // SPIR
: %
[[block_size
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr addrspace
(4), i32
}>, ptr %block
, i32
0, i32
0
28 // AMDGCN
: %
[[block_size
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr
, i32
}>, ptr addrspace
(5) %block
, i32
0, i32
0
29 // SPIR
: store i32
16, ptr %
[[block_size]]
30 // AMDGCN: store i32 20, ptr addrspace(5) %[[block_size]]
31 // SPIR
: %
[[block_align
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr addrspace
(4), i32
}>, ptr %block
, i32
0, i32
1
32 // AMDGCN
: %
[[block_align
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr
, i32
}>, ptr addrspace
(5) %block
, i32
0, i32
1
33 // SPIR
: store i32
4, ptr %
[[block_align]]
34 // AMDGCN: store i32 8, ptr addrspace(5) %[[block_align]]
35 // SPIR
: %
[[block_invoke
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr addrspace
(4), i32
}>, ptr %
[[block
:.
*]], i32
0, i32
2
36 // SPIR
: store ptr addrspace
(4) addrspacecast
(ptr @__foo_block_invoke to ptr addrspace
(4)), ptr %
[[block_invoke]]
37 // SPIR: %[[block_captured:.*]] = getelementptr inbounds <{ i32, i32, ptr addrspace(4), i32 }>, ptr %[[block]], i32 0, i32 3
38 // SPIR: %[[i_value:.*]] = load i32, ptr %i
39 // SPIR: store i32 %[[i_value]], ptr %[[block_captured]],
40 // SPIR: %[[blk_gen_ptr:.*]] = addrspacecast ptr %[[block]] to ptr addrspace(4)
41 // SPIR: store ptr addrspace(4) %[[blk_gen_ptr]], ptr %[[block_B:.*]],
42 // SPIR: %[[block_literal:.*]] = load ptr addrspace(4), ptr %[[block_B]]
43 // SPIR: call {{.*}}i32 @__foo_block_invoke(ptr addrspace(4) noundef %[[block_literal]])
44 // AMDGCN: %[[block_invoke:.*]] = getelementptr inbounds <{ i32, i32, ptr, i32 }>, ptr addrspace(5) %[[block:.*]], i32 0, i32 2
45 // AMDGCN: store ptr @__foo_block_invoke, ptr addrspace(5) %[[block_invoke]]
46 // AMDGCN
: %
[[block_captured
:.
*]] = getelementptr inbounds
<{ i32
, i32
, ptr
, i32
}>, ptr addrspace
(5) %
[[block]], i32 0, i32 3
47 // AMDGCN: %[[i_value:.*]] = load i32, ptr addrspace(5) %i
48 // AMDGCN: store i32 %[[i_value]], ptr addrspace(5) %[[block_captured]],
49 // AMDGCN: %[[blk_gen_ptr:.*]] = addrspacecast ptr addrspace(5) %[[block]] to ptr
50 // AMDGCN
: store ptr %
[[blk_gen_ptr]], ptr addrspace(5) %[[block_B:.*]],
51 // AMDGCN: %[[block_literal:.*]] = load ptr, ptr addrspace(5) %[[block_B]]
52 // AMDGCN: call {{.*}}i32 @__foo_block_invoke(ptr noundef %[[block_literal]])
54 int (^ block_B)(void) = ^{
60 // SPIR-LABEL: define internal {{.*}}i32 @__foo_block_invoke(ptr addrspace(4) noundef %.block_descriptor)
61 // SPIR: %[[block_capture_addr:.*]] = getelementptr inbounds <{ i32, i32, ptr addrspace(4), i32 }>, ptr addrspace(4) %.block_descriptor, i32 0, i32 3
62 // SPIR: %[[block_capture:.*]] = load i32, ptr addrspace(4) %[[block_capture_addr]]
63 // AMDGCN-LABEL: define internal {{.*}}i32 @__foo_block_invoke(ptr noundef %.block_descriptor)
64 // AMDGCN: %[[block_capture_addr:.*]] = getelementptr inbounds <{ i32, i32, ptr, i32 }>, ptr %.block_descriptor, i32 0, i32 3
65 // AMDGCN: %[[block_capture:.*]] = load i32, ptr %[[block_capture_addr]]
67 // COMMON-NOT: define{{.*}}@__foo_block_invoke_kernel
69 // COMMON-LABEL: define {{.*}}@call_block
70 // call {{.*}}@__call_block_block_invoke
72 return ^int(int num) { return num; } (11);
75 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
76 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
78 // CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__isa"
79 // CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__flags"
80 // CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__reserved"
81 // CHECK-DEBUG-NOT: !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr"