Skip to content

Commit

Permalink
Merge pull request #201 from frasercrmck/spirv-ll-valid-tests
Browse files Browse the repository at this point in the history
[spirv-ll] Fix up all LIT tests to be valid SPIR-V (or identified as intentionally invalid)
  • Loading branch information
frasercrmck authored Nov 13, 2023
2 parents 98388a1 + 3382276 commit a61a475
Show file tree
Hide file tree
Showing 135 changed files with 518 additions and 554 deletions.
19 changes: 13 additions & 6 deletions modules/compiler/spirv-ll/test/spvasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,6 @@ set(SPVASM_FILES
op_vector_swizzle_int.spvasm
op_vector_swizzle_long.spvasm
op_vector_swizzle_uint.spvasm
opencl_usm_generic_address_space.spvasm
ptr_int_conversions.spvasm
vec_type_hint_length_1.spvasm
op_opencl_u_ctz_i16.spvasm
Expand Down Expand Up @@ -2137,7 +2136,6 @@ set(SPVASM_FILES
op_opencl_get_local_linear_id.spvasm
op_opencl_get_enqueued_local_size.spvasm
op_opencl_call_byval_arg.spvasm
opencl_max_byte_offset.spvasm
op_expect_assume.spvasm
op_generic_pointer.spvasm
op_generic_pointer_builtin.spvasm
Expand All @@ -2151,14 +2149,21 @@ set(SPVASM_FILES
op_opencl_arg_md.spvasm
unsupported_capability.spvasm
op_get_kernel_preferred_work_group_size_multiple.spvasm
invalid_storage_class.spvasm

# Tests that check behaviour on invalid SPIR-V
invalid-spir-v/invalid_storage_class.spvasm

# Tests that check non-standard Codeplay extensions
codeplay/opencl_usm_generic_address_space.spvasm
)

if(SpirvAsVersion VERSION_GREATER_EQUAL "2020.0")
list(APPEND SPVASM_FILES
op_execution_mode_max_work_dim.spvasm
opencl_group_async_copy_2d2d.spvasm
opencl_group_async_copy_3d3d.spvasm)
# Tests that check non-standard Codeplay extensions
codeplay/opencl_group_async_copy_2d2d.spvasm
codeplay/opencl_group_async_copy_3d3d.spvasm
)
endif()

if (SpirvAsVersion VERSION_GREATER_EQUAL "2021.3")
Expand All @@ -2183,6 +2188,7 @@ endif()
# TODO: It might be more convenient to support a system like UnitCL where test
# files declare their own requirements.
set(SPVASM_V1_1_FILES
opencl_max_byte_offset.spvasm
op_execution_mode_subgroup_size.spvasm
op_execution_mode_subgroups_per_workgroup.spvasm
op_get_default_queue.spvasm
Expand Down Expand Up @@ -2217,10 +2223,11 @@ function(ca_assemble_spirv_ll_lit_test)
set(spvasm "${args_UNPARSED_ARGUMENTS}")

get_filename_component(name ${spvasm} NAME_WE)
get_filename_component(dir ${spvasm} DIRECTORY)

set(test ${CMAKE_CURRENT_BINARY_DIR}/${spvasm})
set(spvasm ${CMAKE_CURRENT_SOURCE_DIR}/${spvasm})
set(spv ${CMAKE_CURRENT_BINARY_DIR}/${name}.spv)
set(spv ${CMAKE_CURRENT_BINARY_DIR}/${dir}/${name}.spv)
if(NOT EXISTS ${spvasm})
message(FATAL_ERROR "spirv-ll input spvasm does not exist: ${spvasm}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -e SPV_codeplay_usm_generic_storage_class -b 64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a OpenCL -e SPV_codeplay_usm_generic_storage_class -b 64 -c GenericPointer %spv_file_s | FileCheck %s
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpCapability GenericPointer
OpExtension "SPV_codeplay_usm_generic_storage_class"
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %11 "test" %__spirv_BuiltInLocalInvocationId %__spirv_BuiltInGlobalInvocationId
OpExtension "SPV_codeplay_usm_generic_storage_class"
OpSource OpenCL_C 102000
OpDecorate %54 Constant
%54 = OpDecorationGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan -c VariablePointersStorageBuffer %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a Vulkan -c VariablePointersStorageBuffer -e SPV_KHR_variable_pointers %spv_file_s | FileCheck %s
; tests that variable pointers work correctly with functions, that they can be
; passed as arguments and returned
OpCapability Shader
OpCapability VariablePointersStorageBuffer
OpExtension "SPV_KHR_variable_pointers"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan -c Float64 -c Int64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a Vulkan -c VariablePointers -e SPV_KHR_variable_pointers %spv_file_s | FileCheck %s

; tests that variable pointers (pointer to pointer type) can be created and that
; they can be produced from an OpConstantNull in accordance with the spec

OpCapability Shader
OpCapability Float64
OpCapability Int64
OpCapability VariablePointers
OpExtension "SPV_KHR_variable_pointers"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
OpCapability Kernel
OpCapability Addresses
OpCapability ArbitraryPrecisionIntegersINTEL
OpExtension "SPV_INTEL_arbitrary_precision_integers"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %kernel "kernel"
OpName %kernel "kernel"
Expand Down
3 changes: 2 additions & 1 deletion modules/compiler/spirv-ll/test/spvasm/intel_opt_none.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

; REQUIRES: spirv-as-v2021.3+
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a OpenCL -b 64 -e SPV_INTEL_optnone %spv_file_s | FileCheck %s
OpCapability Addresses
OpCapability Kernel
OpCapability OptNoneINTEL
OpExtension "SPV_INTEL_optnone"
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %4 "foo"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory contains tests which are invalid SPIR-V as per the
specification, but which we want to test. For example:

* Testing that we correctly identify invalid behaviour.
* Testing that we are flexible and accept invalid SPIR-V and generate something
sensible for it.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
OpCapability Int8
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %54 "_ZTSZN24kernel_bundle_spec_constL22CATCH2_INTERNAL_TEST_4EvE13simple_kernel"
OpSource OpenCL_CPP 100000
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
Expand Down
7 changes: 4 additions & 3 deletions modules/compiler/spirv-ll/test/spvasm/linkonce_odr.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
%1 = OpExtInstImport "OpenCL.std"
OpMemoryModel Physical64 OpenCL
OpSource OpenCL_C 102000
OpDecorate %gv LinkageAttributes "gv" LinkOnceODR
OpDecorate %foo LinkageAttributes "foo" Import
OpDecorate %bar LinkageAttributes "bar" LinkOnceODR

OpName %gv "gv"
OpName %foo "foo"
OpName %bar "bar"
OpName %y "y"

OpDecorate %gv LinkageAttributes "gv" LinkOnceODR
OpDecorate %foo LinkageAttributes "foo" Import
OpDecorate %bar LinkageAttributes "bar" LinkOnceODR

%void = OpTypeVoid
%uint = OpTypeInt 32 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c GenericPointer %spv_file_s | FileCheck %s
OpCapability Kernel
OpCapability Addresses
OpCapability Float64
OpCapability Int64
OpCapability GenericPointer
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %atomic "atomic"
OpName %atomic "atomic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c GenericPointer %spv_file_s | FileCheck %s
OpCapability Kernel
OpCapability Addresses
OpCapability Float64
OpCapability Int64
OpCapability GenericPointer
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %atomic "atomic"
OpName %atomic "atomic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@
OpDecorate %block_t Block
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
%uint = OpTypeInt 32 0
%int = OpTypeInt 32 1
%block_t = OpTypeStruct %int
OpMemberDecorate %block_t 0 Offset 0
%void = OpTypeVoid
%int = OpTypeInt 32 1
%block_t = OpTypeStruct %int
%ptr_Uniform_block_t = OpTypePointer Uniform %block_t
%ptr_Uniform_int = OpTypePointer Uniform %int
%3 = OpTypeFunction %void
%9 = OpConstant %int 424
%uint_1 = OpConstant %uint 1
%uint_0 = OpConstant %uint 0
%block_var = OpVariable %ptr_Uniform_block_t Uniform
%atomic = OpFunction %void None %3
%5 = OpLabel
%a = OpAccessChain %ptr_Uniform_int %block_var %uint_0
%original = OpAtomicCompareExchange %int %a %uint_1 %uint_0 %uint_0 %9 %uint_0
OpReturn
OpFunctionEnd
%ptr_Uniform_int = OpTypePointer Uniform %int
%3 = OpTypeFunction %void
%9 = OpConstant %int 424
%int_1 = OpConstant %int 1
%int_0 = OpConstant %int 0
%block_var = OpVariable %ptr_Uniform_block_t Uniform
%atomic = OpFunction %void None %3
%5 = OpLabel
%a = OpAccessChain %ptr_Uniform_int %block_var %int_0
%original = OpAtomicCompareExchange %int %a %int_1 %int_0 %int_0 %9 %int_0
OpReturn
OpFunctionEnd
; CHECK: ; ModuleID = '{{.*}}'
; CHECK: define spir_kernel void @atomic(ptr addrspace(1){{( %0)?}}, ptr addrspace(1){{( %1)?}})
; CHECK: [[PTR:%[a-zA-Z0-9_]+]] = getelementptr [[BLOCK:%.*]], ptr addrspace(1) [[BLOCK]], i32 0, i32 0
; CHECK: {{%[a-zA-Z0-9_]+}} = call spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viji(ptr addrspace(1) [[PTR]], i32 0, i32 424)
; CHECK: {{%[a-zA-Z0-9_]+}} = call spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viii(ptr addrspace(1) [[PTR]], i32 0, i32 424)
; CHECK: ret void
; CHECK: declare spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viji(ptr addrspace(1), i32, i32)
; CHECK: declare spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viii(ptr addrspace(1), i32, i32)
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_add -c Float64 -c AtomicFloat64AddEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_add"
OpCapability Shader
OpCapability Float64
OpCapability AtomicFloat64AddEXT
OpExtension "SPV_EXT_shader_atomic_float_add"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_min_max -c Float64 -c AtomicFloat64MinMaxEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_min_max"
OpCapability Shader
OpCapability Float64
OpCapability AtomicFloat64MinMaxEXT
OpExtension "SPV_EXT_shader_atomic_float_min_max"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_min_max -c Float64 -c AtomicFloat64MinMaxEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_min_max"
OpCapability Shader
OpCapability Float64
OpCapability AtomicFloat64MinMaxEXT
OpExtension "SPV_EXT_shader_atomic_float_min_max"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 %spv_file_s | FileCheck %s
; RUN: spirv-ll-tool -a OpenCL -b 64 -c Float64 -c GenericPointer %spv_file_s | FileCheck %s
OpCapability Kernel
OpCapability Addresses
OpCapability Float64
OpCapability Int64
OpCapability GenericPointer
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %atomic "atomic"
OpName %atomic "atomic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_add -c AtomicFloat32AddEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_add"
OpCapability Shader
OpCapability AtomicFloat32AddEXT
OpExtension "SPV_EXT_shader_atomic_float_add"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_min_max -c AtomicFloat32MinMaxEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_min_max"
OpCapability Shader
OpCapability AtomicFloat32MinMaxEXT
OpExtension "SPV_EXT_shader_atomic_float_min_max"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@

; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %}
; RUN: spirv-ll-tool -a Vulkan %spv_file_s -e SPV_EXT_shader_atomic_float_min_max -c AtomicFloat32MinMaxEXT | FileCheck %s
OpExtension "SPV_EXT_shader_atomic_float_min_max"
OpCapability Shader
OpCapability AtomicFloat32MinMaxEXT
OpExtension "SPV_EXT_shader_atomic_float_min_max"
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %atomic "atomic"
OpExecutionMode %atomic LocalSize 1 1 1
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OpName %atomic "atomic"
OpName %a "a"
OpDecorate %block_t Block
OpMemberDecorate %block_t 0 Offset 0
OpDecorate %block_var DescriptorSet 0
OpDecorate %block_var Binding 0
%void = OpTypeVoid
Expand Down
Loading

0 comments on commit a61a475

Please sign in to comment.