1; RUN: llvm-as < %s > %t.bc 2; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt 3; RUN: FileCheck < %t.txt %s --check-prefix=SPIRV 4; RUN: llvm-spirv %t.bc -o %t.spv 5; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 6; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=BACK-TO-LLVM 7 8; ModuleID = 'c:/work/tmp/testLink.c' 9target 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" 10target triple = "spir-unknown-unknown" 11 12; SPIRV: Capability Linkage 13; SPIRV: EntryPoint 6 [[kern:[0-9]+]] "kern" 14 15@ae = available_externally addrspace(1) global i32 79, align 4 16; SPIRV: Name [[ae:[0-9]+]] "ae" 17; BACK-TO-LLVM: @ae = available_externally addrspace(1) global i32 79, align 4 18 19@i1 = addrspace(1) global i32 1, align 4 20; SPIRV: Name [[i1:[0-9]+]] "i1" 21; BACK-TO-LLVM: @i1 = addrspace(1) global i32 1, align 4 22 23@i2 = internal addrspace(1) global i32 2, align 4 24; SPIRV: Name [[i2:[0-9]+]] "i2" 25; BACK-TO-LLVM: @i2 = internal addrspace(1) global i32 2, align 4 26 27@i3 = addrspace(1) global i32 3, align 4 28; SPIRV: Name [[i3:[0-9]+]] "i3" 29; BACK-TO-LLVM: @i3 = addrspace(1) global i32 3, align 4 30 31@i4 = common addrspace(1) global i32 0, align 4 32; SPIRV: Name [[i4:[0-9]+]] "i4" 33; BACK-TO-LLVM: @i4 = common addrspace(1) global i32 0, align 4 34 35@i5 = internal addrspace(1) global i32 0, align 4 36; SPIRV: Name [[i5:[0-9]+]] "i5" 37; BACK-TO-LLVM: @i5 = internal addrspace(1) global i32 0, align 4 38 39@color_table = addrspace(2) constant [2 x i32] [i32 0, i32 1], align 4 40; SPIRV: Name [[color_table:[0-9]+]] "color_table" 41; BACK-TO-LLVM: @color_table = addrspace(2) constant [2 x i32] [i32 0, i32 1], align 4 42 43@noise_table = external addrspace(2) constant [256 x i32] 44; SPIRV: Name [[noise_table:[0-9]+]] "noise_table" 45; BACK-TO-LLVM: @noise_table = external addrspace(2) constant [256 x i32] 46 47@w = addrspace(1) constant i32 0, align 4 48; SPIRV: Name [[w:[0-9]+]] "w" 49; BACK-TO-LLVM: @w = addrspace(1) constant i32 0, align 4 50 51@f.color_table = internal addrspace(2) constant [2 x i32] [i32 2, i32 3], align 4 52; SPIRV: Name [[f_color_table:[0-9]+]] "f.color_table" 53; BACK-TO-LLVM: @f.color_table = internal addrspace(2) constant [2 x i32] [i32 2, i32 3], align 4 54 55@e = external addrspace(1) global i32 56; SPIRV: Name [[e:[0-9]+]] "e" 57; BACK-TO-LLVM: @e = external addrspace(1) global i32 58 59@f.t = internal addrspace(1) global i32 5, align 4 60; SPIRV: Name [[f_t:[0-9]+]] "f.t" 61; BACK-TO-LLVM: @f.t = internal addrspace(1) global i32 5, align 4 62 63@f.stint = internal addrspace(1) global i32 0, align 4 64; SPIRV: Name [[f_stint:[0-9]+]] "f.stint" 65; BACK-TO-LLVM: @f.stint = internal addrspace(1) global i32 0, align 4 66 67@f.inside = internal addrspace(1) global i32 0, align 4 68; SPIRV: Name [[f_inside:[0-9]+]] "f.inside" 69; BACK-TO-LLVM: @f.inside = internal addrspace(1) global i32 0, align 4 70 71@f.b = internal addrspace(2) constant float 1.000000e+00, align 4 72; SPIRV: Name [[f_b:[0-9]+]] "f.b" 73; BACK-TO-LLVM: @f.b = internal addrspace(2) constant float 1.000000e+00, align 4 74 75; SPIRV-DAG: Name [[foo:[0-9]+]] "foo" 76; SPIRV-DAG: Name [[f:[0-9]+]] "f" 77; SPIRV-DAG: Name [[g:[0-9]+]] "g" 78; SPIRV-DAG: Name [[inline_fun:[0-9]+]] "inline_fun" 79 80; SPIRV-DAG: Decorate [[ae]] LinkageAttributes "ae" Import 81; SPIRV-DAG: Decorate [[e]] LinkageAttributes "e" Import 82; SPIRV-DAG: Decorate [[f]] LinkageAttributes "f" Export 83; SPIRV-DAG: Decorate [[w]] LinkageAttributes "w" Export 84; SPIRV-DAG: Decorate [[i1]] LinkageAttributes "i1" Export 85; SPIRV-DAG: Decorate [[i3]] LinkageAttributes "i3" Export 86; SPIRV-DAG: Decorate [[i4]] LinkageAttributes "i4" Export 87; SPIRV-DAG: Decorate [[foo]] LinkageAttributes "foo" Import 88; SPIRV-DAG: Decorate [[inline_fun]] LinkageAttributes "inline_fun" Export 89; SPIRV-DAG: Decorate [[color_table]] LinkageAttributes "color_table" Export 90; SPIRV-DAG: Decorate [[noise_table]] LinkageAttributes "noise_table" Import 91 92; SPIRV: Function {{[0-9]+}} [[foo]] 93; BACK-TO-LLVM: declare spir_func void @foo() 94declare spir_func void @foo() #2 95 96; SPIRV: Function {{[0-9]+}} [[f]] 97; BACK-TO-LLVM: define spir_func void @f() 98; Function Attrs: nounwind 99define spir_func void @f() #0 { 100entry: 101 %q = alloca i32, align 4 102 %r = alloca i32, align 4 103 %0 = load i32, i32 addrspace(1)* @i2, align 4 104 store i32 %0, i32* %q, align 4 105 %1 = load i32, i32 addrspace(1)* @i3, align 4 106 store i32 %1, i32 addrspace(1)* @i5, align 4 107 %2 = load i32, i32 addrspace(1)* @e, align 4 108 store i32 %2, i32* %r, align 4 109 %3 = load i32, i32 addrspace(2)* getelementptr inbounds ([256 x i32], [256 x i32] addrspace(2)* @noise_table, i32 0, i32 0), align 4 110 store i32 %3, i32* %r, align 4 111 %4 = load i32, i32 addrspace(2)* getelementptr inbounds ([2 x i32], [2 x i32] addrspace(2)* @f.color_table, i32 0, i32 0), align 4 112 store i32 %4, i32* %r, align 4 113 %call = call spir_func i32 @g() 114 call spir_func void @inline_fun() 115 ret void 116} 117 118; SPIRV: Function {{[0-9]+}} [[g]] 119; BACK-TO-LLVM: define internal spir_func i32 @g() 120; Function Attrs: nounwind 121define internal spir_func i32 @g() #0 { 122entry: 123 call spir_func void @foo() 124 ret i32 25 125} 126 127; SPIRV: Function {{[0-9]+}} [[inline_fun]] 128; BACK-TO-LLVM: define spir_func void @inline_fun() 129; "linkonce_odr" is lost in translation ! 130; Function Attrs: inlinehint nounwind 131define linkonce_odr spir_func void @inline_fun() #1 { 132entry: 133 %t = alloca i32 addrspace(1)*, align 4 134 store i32 addrspace(1)* @i1, i32 addrspace(1)** %t, align 4 135 ret void 136} 137 138; SPIRV: Function {{[0-9]+}} [[kern]] 139; BACK-TO-LLVM: define spir_kernel void @kern() 140; Function Attrs: nounwind 141define spir_kernel void @kern() #0 { 142entry: 143 call spir_func void @f() 144 ret void 145} 146 147attributes #0 = { 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" } 148attributes #1 = { inlinehint 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" } 149attributes #2 = { "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" } 150 151!opencl.kernels = !{!0} 152!opencl.enable.FP_CONTRACT = !{} 153!opencl.spir.version = !{!6} 154!opencl.ocl.version = !{!7} 155!opencl.used.extensions = !{!8} 156!opencl.used.optional.core.features = !{!8} 157!opencl.compiler.options = !{!8} 158 159!0 = !{void ()* @kern, !1, !2, !3, !4, !5} 160!1 = !{!"kernel_arg_addr_space"} 161!2 = !{!"kernel_arg_access_qual"} 162!3 = !{!"kernel_arg_type"} 163!4 = !{!"kernel_arg_base_type"} 164!5 = !{!"kernel_arg_type_qual"} 165!6 = !{i32 1, i32 2} 166!7 = !{i32 2, i32 0} 167!8 = !{} 168