| 1 |
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv1.6-vulkan1.3-library %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-vulkan1.3-library %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" |
| 5 |
|
| 6 |
@.str.b = private unnamed_addr constant [2 x i8] c"B\00", align 1 |
| 7 |
@.str.rwb = private unnamed_addr constant [4 x i8] c"RWB\00", align 1 |
| 8 |
|
| 9 |
; CHECK: OpDecorate [[BufferVar:%.+]] DescriptorSet 0 |
| 10 |
; CHECK: OpDecorate [[BufferVar]] Binding 0 |
| 11 |
; CHECK: OpMemberDecorate [[BufferType:%.+]] 0 Offset 0 |
| 12 |
; CHECK: OpDecorate [[BufferType]] Block |
| 13 |
; CHECK: OpMemberDecorate [[BufferType]] 0 NonWritable |
| 14 |
; CHECK: OpDecorate [[RWBufferVar:%.+]] DescriptorSet 0 |
| 15 |
; CHECK: OpDecorate [[RWBufferVar]] Binding 1 |
| 16 |
; CHECK: OpDecorate [[ArrayType:%.+]] ArrayStride 4 |
| 17 |
; CHECK: OpMemberDecorate [[RWBufferType:%.+]] 0 Offset 0 |
| 18 |
; CHECK: OpDecorate [[RWBufferType]] Block |
| 19 |
|
| 20 |
|
| 21 |
; CHECK: [[int:%[0-9]+]] = OpTypeInt 32 0 |
| 22 |
; CHECK: [[ArrayType]] = OpTypeRuntimeArray |
| 23 |
; CHECK: [[RWBufferType]] = OpTypeStruct [[ArrayType]] |
| 24 |
; CHECK: [[RWBufferPtrType:%.+]] = OpTypePointer StorageBuffer [[RWBufferType]] |
| 25 |
; CHECK: [[BufferType]] = OpTypeStruct [[ArrayType]] |
| 26 |
; CHECK: [[BufferPtrType:%.+]] = OpTypePointer StorageBuffer [[BufferType]] |
| 27 |
; CHECK-DAG: [[zero:%[0-9]+]] = OpConstant [[int]] 0 |
| 28 |
; CHECK-DAG: [[one:%[0-9]+]] = OpConstant [[int]] 1 |
| 29 |
; CHECK-DAG: [[two:%[0-9]+]] = OpConstant [[int]] 2 |
| 30 |
; CHECK-DAG: [[BufferVar]] = OpVariable [[BufferPtrType]] StorageBuffer |
| 31 |
; CHECK-DAG: [[RWBufferVar]] = OpVariable [[RWBufferPtrType]] StorageBuffer |
| 32 |
|
| 33 |
; Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) |
| 34 |
define void @main() local_unnamed_addr #1 { |
| 35 |
entry: |
| 36 |
|
| 37 |
; CHECK-DAG: [[BufferHandle:%.+]] = OpCopyObject [[BufferPtrType]] [[BufferVar]] |
| 38 |
; CHECK-DAG: [[BufferHandle2:%.+]] = OpCopyObject [[BufferPtrType]] [[BufferVar]] |
| 39 |
; CHECK-DAG: [[RWBufferHandle:%.+]] = OpCopyObject [[RWBufferPtrType]] [[RWBufferVar]] |
| 40 |
%BufferHandle = tail call target("spirv.VulkanBuffer", [0 x i32], 12, 0) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0i32_12_0t(i32 0, i32 0, i32 1, i32 0, ptr nonnull @.str.b) |
| 41 |
%BufferHandle2 = tail call target("spirv.VulkanBuffer", [0 x i32], 12, 0) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0i32_12_0t(i32 0, i32 0, i32 1, i32 0, ptr nonnull @.str.b) |
| 42 |
%RWBufferHandle = tail call target("spirv.VulkanBuffer", [0 x i32], 12, 1) @llvm.spv.resource.handlefrombinding.tspirv.VulkanBuffer_a0i32_12_1t(i32 0, i32 1, i32 1, i32 0, ptr nonnull @.str.rwb) |
| 43 |
|
| 44 |
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[BufferHandle]] [[zero]] [[one]] |
| 45 |
%0 = tail call noundef nonnull align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_0t(target("spirv.VulkanBuffer", [0 x i32], 12, 0) %BufferHandle, i32 1) |
| 46 |
|
| 47 |
; CHECK: [[LD:%.+]] = OpLoad [[int]] [[AC]] Aligned 4 |
| 48 |
%1 = load i32, ptr addrspace(11) %0, align 4, !tbaa !3 |
| 49 |
|
| 50 |
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[RWBufferHandle]] [[zero]] [[zero]] |
| 51 |
%2 = tail call noundef nonnull align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_1t(target("spirv.VulkanBuffer", [0 x i32], 12, 1) %RWBufferHandle, i32 0) |
| 52 |
|
| 53 |
; CHECK: OpStore [[AC]] [[LD]] |
| 54 |
store i32 %1, ptr addrspace(11) %2, align 4, !tbaa !3 |
| 55 |
|
| 56 |
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[BufferHandle2]] [[zero]] [[two]] |
| 57 |
%3 = tail call noundef nonnull align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_0t(target("spirv.VulkanBuffer", [0 x i32], 12, 0) %BufferHandle2, i32 2) |
| 58 |
|
| 59 |
; CHECK: [[LD:%.+]] = OpLoad [[int]] [[AC]] Aligned 4 |
| 60 |
%4 = load i32, ptr addrspace(11) %3, align 4, !tbaa !3 |
| 61 |
|
| 62 |
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[RWBufferHandle]] [[zero]] [[zero]] |
| 63 |
%5 = tail call noundef nonnull align 4 dereferenceable(4) ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_1t(target("spirv.VulkanBuffer", [0 x i32], 12, 1) %RWBufferHandle, i32 0) |
| 64 |
|
| 65 |
; CHECK: OpStore [[AC]] [[LD]] |
| 66 |
store i32 %4, ptr addrspace(11) %5, align 4, !tbaa !3 |
| 67 |
ret void |
| 68 |
} |
| 69 |
|
| 70 |
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) |
| 71 |
declare ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_1t(target("spirv.VulkanBuffer", [0 x i32], 12, 1), i32) #0 |
| 72 |
|
| 73 |
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none) |
| 74 |
declare ptr addrspace(11) @llvm.spv.resource.getpointer.p11.tspirv.VulkanBuffer_a0i32_12_0t(target("spirv.VulkanBuffer", [0 x i32], 12, 0), i32) #0 |
| 75 |
|
| 76 |
attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) } |
| 77 |
attributes #1 = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 78 |
|
| 79 |
!llvm.module.flags = !{!0, !1} |
| 80 |
!llvm.ident = !{!2} |
| 81 |
|
| 82 |
!0 = !{i32 1, !"wchar_size", i32 4} |
| 83 |
!1 = !{i32 7, !"frame-pointer", i32 2} |
| 84 |
!2 = !{!"clang version 21.0.0git ([email protected]:s-perron/llvm-project.git 6e86add06c03e328dbb4b83f99406cc832a22f86)"} |
| 85 |
!3 = !{!4, !4, i64 0} |
| 86 |
!4 = !{!"int", !5, i64 0} |
| 87 |
!5 = !{!"omnipotent char", !6, i64 0} |
| 88 |
!6 = !{!"Simple C++ TBAA"} |