1 ; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv1.5-vulkan-library %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.5-vulkan-library %s -o - -filetype=obj | spirv-val %}
4 ; CHECK: OpCapability Shader
5 ; CHECK-NEXT: OpCapability SampledImageArrayDynamicIndexing
6 ; CHECK-NEXT: OpCapability Sampled1D
7 ; CHECK-NOT: OpCapability
9 ; CHECK-DAG: OpDecorate [[Var:%[0-9]+]] DescriptorSet 3
10 ; CHECK-DAG: OpDecorate [[Var]] Binding 4
11 ; CHECK-DAG: OpDecorate [[OtherVar:%[0-9]+]] DescriptorSet 3
12 ; CHECK-DAG: OpDecorate [[OtherVar]] Binding 4
14 ; CHECK-DAG: [[int:%[0-9]+]] = OpTypeInt 32 0
15 ; CHECK-DAG: [[BufferType:%[0-9]+]] = OpTypeImage [[int]] 1D 2 0 0 1 R32i {{$}}
16 ; CHECK-DAG: [[BufferPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferType]]
17 ; CHECK-DAG: [[ArraySize:%[0-9]+]] = OpConstant [[int]] 3
18 ; CHECK-DAG: [[One:%[0-9]+]] = OpConstant [[int]] 1
19 ; CHECK-DAG: [[Zero:%[0-9]+]] = OpConstant [[int]] 0
20 ; CHECK-DAG: [[BufferArrayType:%[0-9]+]] = OpTypeArray [[BufferType]] [[ArraySize]]
21 ; CHECK-DAG: [[ArrayPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[BufferArrayType]]
22 ; CHECK-DAG: [[Var]] = OpVariable [[ArrayPtrType]] UniformConstant
24 ; CHECK-DAG: [[OtherArraySize:%[0-9]+]] = OpConstant [[int]] 5
25 ; CHECK-DAG: [[OtherBufferArrayType:%[0-9]+]] = OpTypeArray [[BufferType]] [[OtherArraySize]]
26 ; CHECK-DAG: [[OtherArrayPtrType:%[0-9]+]] = OpTypePointer UniformConstant [[OtherBufferArrayType]]
27 ; CHECK-DAG: [[OtherVar]] = OpVariable [[OtherArrayPtrType]] UniformConstant
29 ; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}}
31 define void @main() #0 {
32 ; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[Zero]]
33 ; CHECK: [[buffer:%[0-9]+]] = OpLoad [[BufferType]] [[ac]]
34 %buffer0 = call target("spirv.Image", i32, 0, 2, 0, 0, 1, 24)
35 @llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24(
36 i32 3, i32 4, i32 3, i32 0, i1 false)
38 ; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[One]]
39 ; CHECK: [[buffer:%[0-9]+]] = OpLoad [[BufferType]] [[ac]]
40 %buffer1 = call target("spirv.Image", i32, 0, 2, 0, 0, 1, 24)
41 @llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24(
42 i32 3, i32 4, i32 3, i32 1, i1 false)
46 ; CHECK: {{%[0-9]+}} = OpFunction {{%[0-9]+}} DontInline {{%[0-9]+}}
48 define void @DifferentArraySizesAreDifferentVariables() #0 {
49 ; Make sure we use different variables when the array sizes are different
50 ; same in case one function calls the other.
51 ; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[Var]] [[Zero]]
52 ; CHECK: [[buffer:%[0-9]+]] = OpLoad [[BufferType]] [[ac]]
53 %buffer0 = call target("spirv.Image", i32, 0, 2, 0, 0, 1, 24)
54 @llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24(
55 i32 3, i32 4, i32 3, i32 0, i1 false)
57 ; CHECK: [[ac:%[0-9]+]] = OpAccessChain [[BufferPtrType]] [[OtherVar]] [[One]]
58 ; CHECK: [[buffer:%[0-9]+]] = OpLoad [[BufferType]] [[ac]]
59 %buffer1 = call target("spirv.Image", i32, 0, 2, 0, 0, 1, 24)
60 @llvm.spv.handle.fromBinding.tspirv.Image_f32_0_2_0_0_1_24(
61 i32 3, i32 4, i32 5, i32 1, i1 false)
65 attributes #0 = { convergent noinline norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }