1; RUN: llvm-as < %s | llvm-spirv -spirv-text -o %t 2; RUN: FileCheck < %t %s 3 4; check for magic number followed by version 1.1 5; CHECK: 119734787 65792 6 7; CHECK-DAG: TypeVoid [[VOID:[0-9]+]] 8 9; CHECK-DAG: EntryPoint 6 [[WORKER:[0-9]+]] "worker" 10; CHECK-DAG: EntryPoint 6 [[INIT:[0-9]+]] "_SPIRV_GLOBAL__I_45b04794_Test_attr.cl" 11; CHECK-DAG: EntryPoint 6 [[FIN:[0-9]+]] "_SPIRV_GLOBAL__D_45b04794_Test_attr.cl" 12 13; CHECK-DAG: ExecutionMode [[WORKER]] 17 10 10 10 14; CHECK-DAG: ExecutionMode [[WORKER]] 18 12 10 1 15; CHECK-DAG: ExecutionMode [[WORKER]] 30 262149 16; CHECK-DAG: ExecutionMode [[WORKER]] 36 4 17; CHECK-DAG: ExecutionMode [[INIT]] 17 1 1 1 18; CHECK-DAG: ExecutionMode [[INIT]] 33 19; CHECK-DAG: ExecutionMode [[FIN]] 17 1 1 1 20; CHECK-DAG: ExecutionMode [[FIN]] 34 21 22target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 23target triple = "spir-unknown-unknown" 24 25%struct.global_ctor_dtor = type { i32 } 26 27@g = addrspace(1) global %struct.global_ctor_dtor zeroinitializer, align 4 28 29; Function Attrs: nounwind 30define internal spir_func void @__cxx_global_var_init() #0 { 31entry: 32 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) 33 ret void 34} 35 36; Function Attrs: nounwind 37define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC1Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr #1 align 2 { 38entry: 39 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4 40 %i.addr = alloca i32, align 4 41 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4 42 store i32 %i, i32* %i.addr, align 4 43 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr 44 %0 = load i32, i32* %i.addr, align 4 45 call spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this1, i32 %0) 46 ret void 47} 48 49; Function Attrs: nounwind 50define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD1Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr #1 align 2 { 51entry: 52 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4 53 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4 54 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr 55 call spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this1) #0 56 ret void 57} 58 59; Function Attrs: nounwind 60define internal spir_func void @__dtor_g() #0 { 61entry: 62 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)*)) 63 ret void 64} 65 66; CHECK: Function [[VOID]] [[WORKER]] 67 68; Function Attrs: nounwind 69define spir_kernel void @worker() #1 { 70entry: 71 ret void 72} 73 74; Function Attrs: nounwind 75define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorD2Ev(%struct.global_ctor_dtor addrspace(4)* %this) unnamed_addr #1 align 2 { 76entry: 77 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4 78 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4 79 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr 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 82 ret void 83} 84 85; Function Attrs: nounwind 86define linkonce_odr spir_func void @_ZNU3AS416global_ctor_dtorC2Ei(%struct.global_ctor_dtor addrspace(4)* %this, i32 %i) unnamed_addr #1 align 2 { 87entry: 88 %this.addr = alloca %struct.global_ctor_dtor addrspace(4)*, align 4 89 %i.addr = alloca i32, align 4 90 store %struct.global_ctor_dtor addrspace(4)* %this, %struct.global_ctor_dtor addrspace(4)** %this.addr, align 4 91 store i32 %i, i32* %i.addr, align 4 92 %this1 = load %struct.global_ctor_dtor addrspace(4)*, %struct.global_ctor_dtor addrspace(4)** %this.addr 93 %0 = load i32, i32* %i.addr, align 4 94 %a = getelementptr inbounds %struct.global_ctor_dtor, %struct.global_ctor_dtor addrspace(4)* %this1, i32 0, i32 0 95 store i32 %0, i32 addrspace(4)* %a, align 4 96 ret void 97} 98 99; Function Attrs: nounwind 100define internal spir_func void @_GLOBAL__sub_I_Test_attr.cl() #0 { 101entry: 102 call spir_func void @__cxx_global_var_init() 103 ret void 104} 105 106; CHECK: Function [[VOID]] [[INIT]] 107 108; Function Attrs: noinline nounwind 109define spir_kernel void @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl() #2 { 110entry: 111 call spir_func void @_GLOBAL__sub_I_Test_attr.cl() 112 ret void 113} 114 115; CHECK: Function [[VOID]] [[FIN]] 116 117; Function Attrs: noinline nounwind 118define spir_kernel void @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl() #2 { 119entry: 120 call spir_func void @__dtor_g() 121 ret void 122} 123 124attributes #0 = { nounwind } 125attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 126attributes #2 = { noinline nounwind } 127 128!spirv.ExecutionMode = !{!0, !1, !2, !3, !4, !5, !6, !7} 129!opencl.enable.FP_CONTRACT = !{} 130!opencl.spir.version = !{!8} 131!opencl.ocl.version = !{!9} 132!opencl.used.extensions = !{!10} 133!opencl.used.optional.core.features = !{!10} 134!opencl.compiler.options = !{!10} 135!llvm.ident = !{!11} 136!spirv.Source = !{!12} 137 138!0 = !{void ()* @worker, i32 30, i32 262149} 139!1 = !{void ()* @worker, i32 18, i32 12, i32 10, i32 1} 140!2 = !{void ()* @worker, i32 17, i32 10, i32 10, i32 10} 141!3 = !{void ()* @worker, i32 36, i32 4} 142!4 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 33} 143!5 = !{void ()* @_SPIRV_GLOBAL__I_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1} 144!6 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 34} 145!7 = !{void ()* @_SPIRV_GLOBAL__D_45b04794_Test_attr.cl, i32 17, i32 1, i32 1, i32 1} 146!8 = !{i32 1, i32 2} 147!9 = !{i32 2, i32 2} 148!10 = !{} 149!11 = !{!"clang version 3.6.1 "} 150!12 = !{i32 4, i32 202000} 151