1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
4 ; CHECK-DAG: %[[#VOID:]] = OpTypeVoid
6 ; CHECK-DAG: OpEntryPoint Kernel %[[#WORKER:]] "worker"
7 ; CHECK-DAG: OpEntryPoint Kernel %[[#INIT:]] "_SPIRV_GLOBAL__I_45b04794_Test_attr.cl"
8 ; CHECK-DAG: OpEntryPoint Kernel %[[#FIN:]] "_SPIRV_GLOBAL__D_45b04794_Test_attr.cl"
10 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] LocalSize 10 10 10
11 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] LocalSizeHint 12 10 1
12 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] VecTypeHint 262149
13 ; CHECK-DAG: OpExecutionMode %[[#WORKER]] SubgroupsPerWorkgroup 4
14 ; CHECK-DAG: OpExecutionMode %[[#INIT]] LocalSize 1 1 1
15 ; CHECK-DAG: OpExecutionMode %[[#INIT]] Initializer
16 ; CHECK-DAG: OpExecutionMode %[[#FIN]] LocalSize 1 1 1
17 ; CHECK-DAG: OpExecutionMode %[[#FIN]] Finalizer
19 %struct.global_ctor_dtor = type { i32 }
21 @g = addrspace(1) global %struct.global_ctor_dtor zeroinitializer, align 4
23 define internal spir_func void @__cxx_global_var_init() {
25 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)
29 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC1Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr align 2 {
31 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
32 %i.addr = alloca i32, align 4
33 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
34 store i32 %i, i32* %i.addr, align 4
35 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
36 %0 = load i32, i32* %i.addr, align 4
37 call spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this1, i32 %0)
41 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD1Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr align 2 {
43 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
44 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
45 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
46 call spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this1)
50 define internal spir_func void @__dtor_g() {
52 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)*))
56 ; CHECK: %[[#WORKER]] = OpFunction %[[#VOID]]
58 define spir_kernel void @worker() {
63 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr align 2 {
65 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
66 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
67 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
68 %a = getelementptr inbounds %struct.global_ctor_dtor, %struct.global_ctor_dtor addrspace(4)* %this1, i32 0, i32 0
69 store i32 0, i32 addrspace(4)* %a, align 4
73 define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr align 2 {
75 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4
76 %i.addr = alloca i32, align 4
77 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4
78 store i32 %i, i32* %i.addr, align 4
79 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr
80 %0 = load i32, i32* %i.addr, align 4
81 %a = getelementptr inbounds %struct.global_ctor_dtor, %struct.global_ctor_dtor addrspace(4)* %this1, i32 0, i32 0
82 store i32 %0, i32 addrspace(4)* %a, align 4
86 define internal spir_func void @_GLOBAL__sub_I_Test_attr.cl() {
88 call spir_func void @__cxx_global_var_init()
92 ; CHECK: %[[#INIT]] = OpFunction %[[#VOID]]
94 define spir_kernel void @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl() {
96 call spir_func void @_GLOBAL__sub_I_Test_attr.cl()
100 ; CHECK: %[[#FIN]] = OpFunction %[[#VOID]]
102 define spir_kernel void @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl() {
104 call spir_func void @__dtor_g()
108 !spirv.ExecutionMode = !{!0, !1, !2, !3, !4, !5, !6, !7}
110 !0 = !{void ()* @worker, i32 30, i32 262149}
111 !1 = !{void ()* @worker, i32 18, i32 12, i32 10, i32 1}
112 !2 = !{void ()* @worker, i32 17, i32 10, i32 10, i32 10}
113 !3 = !{void ()* @worker, i32 36, i32 4}
114 !4 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 33}
115 !5 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1}
116 !6 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 34}
117 !7 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1}