1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: %[[#VOID:]] = OpTypeVoid
5 ; CHECK-DAG: OpEntryPoint Kernel %[[#WORKER:]] "worker"
6 ; CHECK-DAG: OpEntryPoint Kernel %[[#INIT:]] "_SPIRV_GLOBAL__I_45b04794_Test_attr.cl"
7 ; CHECK-DAG: OpEntryPoint Kernel %[[#FIN:]] "_SPIRV_GLOBAL__D_45b04794_Test_attr.cl"
9 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] LocalSize 10 10 10
10 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] LocalSizeHint 12 10 1
11 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] VecTypeHint 262149
12 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] SubgroupsPerWorkgroup 4
13 ; CHECK-DAG: OpExecutionMode %[[#INIT]] LocalSize 1 1 1
14 ; CHECK-DAG: OpExecutionMode %[[#INIT]] Initializer
15 ; CHECK-DAG: OpExecutionMode %[[#FIN]] LocalSize 1 1 1
16 ; CHECK-DAG: OpExecutionMode %[[#FIN]] Finalizer
18 %struct.global_ctor_dtor = type { i32 }
20 @g = addrspace(1) global %struct.global_ctor_dtor zeroinitializer, align 4
22 define internal spir_func void @__cxx_global_var_init() {
24 call spir_func void @_ZNU3AS416global_ctor_dtorC1Ei(%struct.global_ctor_dtor addrspace(4)* addrspacecast (%struct.global_ctor_dtor addrspace(1)* @g to %struct.global_ctor_dtor addrspace(4)*), i32 12)
28 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC1Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr align 2 {
30 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
31 %i.addr = alloca i32, align 4
32 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
33 store i32 %i, i32* %i.addr, align 4
34 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
35 %0 = load i32, i32* %i.addr, align 4
36 call spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this1, i32 %0)
40 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD1Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr align 2 {
42 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
43 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
44 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
45 call spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this1)
49 define internal spir_func void @__dtor_g() {
51 call spir_func void @_ZNU3AS416global_ctor_dtorD1Ev(%struct.global_ctor_dtor addrspace(4)* addrspacecast (%struct.global_ctor_dtor addrspace(1)* @g to %struct.global_ctor_dtor addrspace(4)*))
55 ; CHECK: %[[#WORKER]] = OpFunction %[[#VOID]]
57 define spir_kernel void @worker() {
62 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr align 2 {
64 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
65 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
66 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
67 %a = getelementptr inbounds %struct.global_ctor_dtor, %struct.global_ctor_dtor addrspace(4)* %this1, i32 0, i32 0
68 store i32 0, i32 addrspace(4)* %a, align 4
72 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr align 2 {
74 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
75 %i.addr = alloca i32, align 4
76 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
77 store i32 %i, i32* %i.addr, align 4
78 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
79 %0 = load i32, i32* %i.addr, align 4
80 %a = getelementptr inbounds %struct.global_ctor_dtor, %struct.global_ctor_dtor addrspace(4)* %this1, i32 0, i32 0
81 store i32 %0, i32 addrspace(4)* %a, align 4
85 define internal spir_func void @_GLOBAL__sub_I_Test_attr.cl() {
87 call spir_func void @__cxx_global_var_init()
91 ; CHECK: %[[#INIT]] = OpFunction %[[#VOID]]
93 define spir_kernel void @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl() {
95 call spir_func void @_GLOBAL__sub_I_Test_attr.cl()
99 ; CHECK: %[[#FIN]] = OpFunction %[[#VOID]]
101 define spir_kernel void @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl() {
103 call spir_func void @__dtor_g()
107 !spirv.ExecutionMode = !{!0, !1, !2, !3, !4, !5, !6, !7}
109 !0 = !{void ()* @worker, i32 30, i32 262149}
110 !1 = !{void ()* @worker, i32 18, i32 12, i32 10, i32 1}
111 !2 = !{void ()* @worker, i32 17, i32 10, i32 10, i32 10}
112 !3 = !{void ()* @worker, i32 36, i32 4}
113 !4 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 33}
114 !5 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1}
115 !6 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 34}
116 !7 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1}