Add spirv-dis (disassembler) and spirv-val (validator) from SPIRV-Tools as external dependencies for testing the SPIR-V backend. These tools are test dependencies only. SPIR-V backend tests now have a dependency on the spirv-dis and spirv-val targets when the `LLVM_INCLUDE_SPIRV_TOOLS_TESTS` cmake variable is set, which allows additional test files with the `REQUIRES: spirv-tools` constraint to run, along with additional `RUN: %if spirv-tools ...` lines in existing tests. All other SPIR-V backend tests will run normally when `LLVM_INCLUDE_SPIRV_TOOLS_TESTS` is not set. Several tests are included to show these tools' use, however more tests will be migrated and added later. * OpVariable_order.ll shows how spirv-val can catch bugs in the backend. * basic_int_types_spirvdis.ll shows how tests can be much shorter and more readable by FileChecking the spirv-dis output. * basic_int_types.ll shows how an additional RUN line can add validation to existing tests. RFC: https://discourse.llvm.org/t/rfc-add-a-test-dependency-on-spirv-tools/75135
18 lines
648 B
LLVM
18 lines
648 B
LLVM
; REQUIRES: spirv-tools
|
|
; RUN: llc -O0 -mtriple=spirv-unknown-linux %s -o - -filetype=obj | not spirv-val 2>&1 | FileCheck %s
|
|
|
|
; TODO(#66261): The SPIR-V backend should reorder OpVariable instructions so this doesn't fail,
|
|
; but in the meantime it's a good example of the spirv-val tool working as intended.
|
|
|
|
; CHECK: All OpVariable instructions in a function must be the first instructions in the first block.
|
|
|
|
define void @main() #1 {
|
|
entry:
|
|
%0 = alloca <2 x i32>, align 4
|
|
%1 = getelementptr <2 x i32>, ptr %0, i32 0, i32 0
|
|
%2 = alloca float, align 4
|
|
ret void
|
|
}
|
|
|
|
attributes #1 = { "hlsl.numthreads"="4,8,16" "hlsl.shader"="compute" }
|