The "topological" sorting was behaving incorrectly in some cases: the exit of a loop could have a lower rank than a node in the loop. This causes issues when structurizing some patterns, and also codegen issues as we could generate BBs in the incorrect order in regard to the SPIR-V spec. Fixing this ordering alone broke other parts of the structurizer, which by luck worked. Had to fix those. Added more test cases, especially to test basic patterns. I also needed to tweak/disable some tests for 2 reasons: - SPIR-V now required reg2mem/mem2reg to run. Meaning dead stores are optimized away. Some tests require tweaks to avoid having the whole function removed. - Mem2Reg will generate variable & load/stores. This generates G_BITCAST in several cases. And there is currently something wrong we do with G_BITCAST which causes MIR verifier to complain. Until this is resolved, I disabled -verify-machineinstrs flag on those tests. --------- Signed-off-by: Nathan Gauër <brioche@google.com>
22 lines
696 B
LLVM
22 lines
696 B
LLVM
; All OpVariable instructions in a function must be the first instructions in the first block
|
|
|
|
; RUN: llc -O0 -mtriple=spirv32-unknown-linux %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-linux %s -o - -filetype=obj | spirv-val %}
|
|
|
|
; CHECK-SPIRV: OpFunction
|
|
; CHECK-SPIRV-NEXT: OpLabel
|
|
; CHECK-SPIRV-NEXT: OpVariable
|
|
; CHECK-SPIRV-NEXT: OpVariable
|
|
; CHECK-SPIRV: OpReturn
|
|
; CHECK-SPIRV: OpFunctionEnd
|
|
|
|
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" }
|