1; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIRV 2 3; SPIRV: OpCapability Linkage 4; SPIRV: OpEntryPoint Kernel %[[#kern:]] "kern" 5 6@ae = available_externally addrspace(1) global i32 79, align 4 7; SPIRV-DAG: OpName %[[#ae:]] "ae" 8 9@i1 = addrspace(1) global i32 1, align 4 10; SPIRV-DAG: OpName %[[#i1:]] "i1" 11 12@i2 = internal addrspace(1) global i32 2, align 4 13; SPIRV-DAG: OpName %[[#i2:]] "i2" 14 15@i3 = addrspace(1) global i32 3, align 4 16; SPIRV-DAG: OpName %[[#i3:]] "i3" 17 18@i4 = common addrspace(1) global i32 0, align 4 19; SPIRV-DAG: OpName %[[#i4:]] "i4" 20 21@i5 = internal addrspace(1) global i32 0, align 4 22; SPIRV-DAG: OpName %[[#i5:]] "i5" 23 24@color_table = addrspace(2) constant [2 x i32] [i32 0, i32 1], align 4 25; SPIRV-DAG: OpName %[[#color_table:]] "color_table" 26 27@noise_table = external addrspace(2) constant [256 x i32] 28; SPIRV-DAG: OpName %[[#noise_table:]] "noise_table" 29 30@w = addrspace(1) constant i32 0, align 4 31; SPIRV-DAG: OpName %[[#w:]] "w" 32 33@f.color_table = internal addrspace(2) constant [2 x i32] [i32 2, i32 3], align 4 34; SPIRV-DAG: OpName %[[#f_color_table:]] "f.color_table" 35 36@e = external addrspace(1) global i32 37; SPIRV-DAG: OpName %[[#e:]] "e" 38 39@f.t = internal addrspace(1) global i32 5, align 4 40; SPIRV-DAG: OpName %[[#f_t:]] "f.t" 41 42@f.stint = internal addrspace(1) global i32 0, align 4 43; SPIRV-DAG: OpName %[[#f_stint:]] "f.stint" 44 45@f.inside = internal addrspace(1) global i32 0, align 4 46; SPIRV-DAG: OpName %[[#f_inside:]] "f.inside" 47 48@f.b = internal addrspace(2) constant float 1.000000e+00, align 4 49; SPIRV-DAG: OpName %[[#f_b:]] "f.b" 50 51; SPIRV-DAG: OpName %[[#foo:]] "foo" 52; SPIRV-DAG: OpName %[[#f:]] "f" 53; SPIRV-DAG: OpName %[[#g:]] "g" 54; SPIRV-DAG: OpName %[[#inline_fun:]] "inline_fun" 55 56; SPIRV-DAG: OpDecorate %[[#ae]] LinkageAttributes "ae" Import 57; SPIRV-DAG: OpDecorate %[[#e]] LinkageAttributes "e" Import 58; SPIRV-DAG: OpDecorate %[[#f]] LinkageAttributes "f" Export 59; SPIRV-DAG: OpDecorate %[[#w]] LinkageAttributes "w" Export 60; SPIRV-DAG: OpDecorate %[[#i1]] LinkageAttributes "i1" Export 61; SPIRV-DAG: OpDecorate %[[#i3]] LinkageAttributes "i3" Export 62; SPIRV-DAG: OpDecorate %[[#i4]] LinkageAttributes "i4" Export 63; SPIRV-DAG: OpDecorate %[[#foo]] LinkageAttributes "foo" Import 64; SPIRV-DAG: OpDecorate %[[#inline_fun]] LinkageAttributes "inline_fun" Export 65; SPIRV-DAG: OpDecorate %[[#color_table]] LinkageAttributes "color_table" Export 66; SPIRV-DAG: OpDecorate %[[#noise_table]] LinkageAttributes "noise_table" Import 67 68; SPIRV: %[[#foo]] = OpFunction %[[#]] 69declare spir_func void @foo() 70 71; SPIRV: %[[#f]] = OpFunction %[[#]] 72define spir_func void @f() { 73entry: 74 %q = alloca i32, align 4 75 %r = alloca i32, align 4 76 %0 = load i32, i32 addrspace(1)* @i2, align 4 77 store i32 %0, i32* %q, align 4 78 %1 = load i32, i32 addrspace(1)* @i3, align 4 79 store i32 %1, i32 addrspace(1)* @i5, align 4 80 %2 = load i32, i32 addrspace(1)* @e, align 4 81 store i32 %2, i32* %r, align 4 82 %3 = load i32, i32 addrspace(2)* getelementptr inbounds ([256 x i32], [256 x i32] addrspace(2)* @noise_table, i32 0, i32 0), align 4 83 store i32 %3, i32* %r, align 4 84 %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 85 store i32 %4, i32* %r, align 4 86 %call = call spir_func i32 @g() 87 call spir_func void @inline_fun() 88 ret void 89} 90 91; SPIRV: %[[#g]] = OpFunction %[[#]] 92define internal spir_func i32 @g() { 93entry: 94 call spir_func void @foo() 95 ret i32 25 96} 97 98; SPIRV: %[[#inline_fun]] = OpFunction %[[#]] 99;; "linkonce_odr" is lost in translation ! 100define linkonce_odr spir_func void @inline_fun() { 101entry: 102 %t = alloca i32 addrspace(1)*, align 4 103 store i32 addrspace(1)* @i1, i32 addrspace(1)** %t, align 4 104 ret void 105} 106 107; SPIRV: %[[#kern]] = OpFunction %[[#]] 108define spir_kernel void @kern() { 109entry: 110 call spir_func void @f() 111 ret void 112} 113