Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,12 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeArray(uint32_t NumElems,
.addUse(NumElementsVReg);
});
} else {
assert(ST.isShader() && "Runtime arrays are not allowed in non-shader "
"SPIR-V modules.");
if (!ST.isShader())
if (!ST.isShader()) {
llvm::reportFatalUsageError(
"Runtime arrays are not allowed in non-shader "
"SPIR-V modules");
return nullptr;
}
ArrayType = createOpType(MIRBuilder, [&](MachineIRBuilder &MIRBuilder) {
return MIRBuilder.buildInstr(SPIRV::OpTypeRuntimeArray)
.addDef(createTypeVReg(MIRBuilder))
Expand Down
10 changes: 8 additions & 2 deletions llvm/test/CodeGen/SPIRV/zero-length-array.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - | FileCheck %s
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-vulkan-compute < %s | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}

; Nothing is generated, but compilation doesn't crash.
; RUN: not llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown < %s 2>&1 | FileCheck -check-prefix=CHECK-ERR %s

; For compute, nothing is generated, but compilation doesn't crash.
; CHECK: OpName %[[#FOO:]] "foo"
; CHECK: OpName %[[#RTM:]] "reg2mem alloca point"
; CHECK: %[[#INT:]] = OpTypeInt 32 0
Expand All @@ -11,6 +13,10 @@
; CHECK-NEXT: OpReturn
; CHECK-NEXT: OpFunctionEnd


; For non-compute, error.
; CHECK-ERR: LLVM ERROR: Runtime arrays are not allowed in non-shader SPIR-V modules

define spir_func void @foo() {
entry:
%i = alloca [0 x i32], align 4
Expand Down
Loading