Skip to content

Commit cf94fd0

Browse files
committed
Fixes from code review.
1 parent 17f0af3 commit cf94fd0

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,8 @@ SPIRVType *SPIRVGlobalRegistry::getOrCreateVulkanBufferType(
13311331
if (const MachineInstr *MI = findMI(Key, &MIRBuilder.getMF()))
13321332
return MI;
13331333

1334-
// TODO: The SPIRVType for `ElemType` will not have an explicit layout.
1335-
// This generates invalid SPIR-V.
1334+
// TODO(134119): The SPIRVType for `ElemType` will not have an explicit
1335+
// layout. This generates invalid SPIR-V.
13361336
auto *T = StructType::create(ElemType);
13371337
auto *BlockType =
13381338
getOrCreateSPIRVType(T, MIRBuilder, SPIRV::AccessQualifier::None, EmitIr);

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@ void SPIRVModuleAnalysis::setBaseInfo(const Module &M) {
214214
}
215215
}
216216

217-
static InstrSignature instrToSignature(const MachineInstr &MI,
218-
SPIRV::ModuleAnalysisInfo &MAI,
219-
bool UseDefReg);
220-
221217
// Appends the signature of the decoration instructions that decorate R to
222218
// Signature.
223219
static void appendDecorationsForReg(const MachineRegisterInfo &MRI, Register R,

llvm/test/CodeGen/SPIRV/hlsl-resources/StructuredBuffer.ll

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ declare target("spirv.VulkanBuffer", [0 x i32], 12, 1) @llvm.spv.resource.handle
2828
; CHECK: [[BufferPtrType:%.+]] = OpTypePointer StorageBuffer [[BufferType]]
2929
; CHECK-DAG: [[zero:%[0-9]+]] = OpConstant [[int]] 0
3030
; CHECK-DAG: [[one:%[0-9]+]] = OpConstant [[int]] 1
31+
; CHECK-DAG: [[two:%[0-9]+]] = OpConstant [[int]] 2
3132
; CHECK-DAG: [[BufferVar]] = OpVariable [[BufferPtrType]] StorageBuffer
3233
; CHECK-DAG: [[RWBufferVar]] = OpVariable [[RWBufferPtrType]] StorageBuffer
3334

@@ -36,22 +37,35 @@ define void @main() local_unnamed_addr #1 {
3637
entry:
3738

3839
; CHECK-DAG: [[BufferHandle:%.+]] = OpCopyObject [[BufferPtrType]] [[BufferVar]]
40+
; CHECK-DAG: [[BufferHandle2:%.+]] = OpCopyObject [[BufferPtrType]] [[BufferVar]]
3941
; CHECK-DAG: [[RWBufferHandle:%.+]] = OpCopyObject [[RWBufferPtrType]] [[RWBufferVar]]
40-
%_ZL1i_h.i.i = 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, i1 false)
41-
42-
%_ZL1o_h.i.i = 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, i1 false)
42+
%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, i1 false)
43+
%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, i1 false)
44+
%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, i1 false)
4345

4446
; 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) %_ZL1i_h.i.i, i32 1)
47+
%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)
4648

4749
; CHECK: [[LD:%.+]] = OpLoad [[int]] [[AC]] Aligned 4
4850
%1 = load i32, ptr addrspace(11) %0, align 4, !tbaa !3
4951

5052
; 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) %_ZL1o_h.i.i, i32 0)
53+
%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)
5254

5355
; CHECK: OpStore [[AC]] [[LD]]
5456
store i32 %1, ptr addrspace(11) %2, align 4, !tbaa !3
57+
58+
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[BufferHandle2]] [[zero]] [[two]]
59+
%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)
60+
61+
; CHECK: [[LD:%.+]] = OpLoad [[int]] [[AC]] Aligned 4
62+
%4 = load i32, ptr addrspace(11) %3, align 4, !tbaa !3
63+
64+
; CHECK: [[AC:%.+]] = OpAccessChain {{.*}} [[RWBufferHandle]] [[zero]] [[zero]]
65+
%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)
66+
67+
; CHECK: OpStore [[AC]] [[LD]]
68+
store i32 %4, ptr addrspace(11) %5, align 4, !tbaa !3
5569
ret void
5670
}
5771

0 commit comments

Comments
 (0)