This PR fixes issue https://github.com/llvm/llvm-project/issues/87763 and preserves valid CFG in cases when previous scheme failed to generate valid code for a switch statement. The PR hardens one existing test case and adds one more test case as a validation of a new switch generation. Tests are passing spirv-val now. This PR also improves validation of forward calls.
22 lines
694 B
LLVM
22 lines
694 B
LLVM
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
|
|
define void @test_switch_with_unreachable_block(i1 %a) {
|
|
%value = zext i1 %a to i32
|
|
; CHECK-SPIRV: OpSwitch %[[#]] %[[#UNREACHABLE:]] 0 %[[#REACHABLE:]] 1 %[[#REACHABLE:]]
|
|
switch i32 %value, label %unreachable [
|
|
i32 0, label %reachable
|
|
i32 1, label %reachable
|
|
]
|
|
|
|
; CHECK-SPIRV-NEXT: %[[#REACHABLE]] = OpLabel
|
|
reachable:
|
|
; CHECK-SPIRV-NEXT: OpReturn
|
|
ret void
|
|
|
|
; CHECK-SPIRV: %[[#UNREACHABLE]] = OpLabel
|
|
; CHECK-SPIRV-NEXT: OpUnreachable
|
|
unreachable:
|
|
unreachable
|
|
}
|