mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Type annotations for instruction operands are omitted, e.g. ``` %3 = struct $S(%1, %2) ``` Operand types are redundant anyway and were only used for sanity checking in the SIL parser. But: operand types _are_ printed if the definition of the operand value was not printed yet. This happens: * if the block with the definition appears after the block where the operand's instruction is located * if a block or instruction is printed in isolation, e.g. in a debugger The old behavior can be restored with `-Xllvm -sil-print-types`. This option is added to many existing test files which check for operand types in their check-lines.
96 lines
2.5 KiB
Plaintext
96 lines
2.5 KiB
Plaintext
// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -jumpthread-simplify-cfg | %FileCheck %s
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
enum E {
|
|
case A
|
|
case B
|
|
case C
|
|
}
|
|
|
|
enum GenE<T> {
|
|
case A
|
|
case B
|
|
case C(T)
|
|
}
|
|
|
|
sil @external_f : $@convention(thin) () -> ()
|
|
|
|
// CHECK-LABEL: sil @test_switch_enum
|
|
sil @test_switch_enum : $@convention(thin) (E) -> Int32 {
|
|
bb0(%0 : $E):
|
|
// CHECK: switch_enum %0 : $E, case #E.A!enumelt: bb1, case #E.B!enumelt: bb2, case #E.C!enumelt: bb3
|
|
switch_enum %0 : $E, case #E.A!enumelt: bb1, case #E.B!enumelt: bb2, default bb3
|
|
|
|
bb1:
|
|
%2 = integer_literal $Builtin.Int32, 10
|
|
br bb4(%2 : $Builtin.Int32)
|
|
|
|
bb2:
|
|
%21 = function_ref @external_f : $@convention(thin) () -> ()
|
|
%22 = apply %21() : $@convention(thin) () -> ()
|
|
%23 = integer_literal $Builtin.Int32, 20
|
|
br bb4(%23 : $Builtin.Int32)
|
|
|
|
bb3:
|
|
%6 = integer_literal $Builtin.Int32, 30
|
|
br bb4(%6 : $Builtin.Int32)
|
|
|
|
bb4(%8 : $Builtin.Int32):
|
|
%9 = struct $Int32 (%8 : $Builtin.Int32)
|
|
return %9 : $Int32
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_switch_enum_addr
|
|
sil @test_switch_enum_addr : $@convention(thin) <T> (@in GenE<T>) -> Int32 {
|
|
bb0(%0 : $*GenE<T>):
|
|
%1 = alloc_stack $GenE<T>
|
|
copy_addr %0 to [init] %1 : $*GenE<T>
|
|
// CHECK: switch_enum_addr %1 : $*GenE<T>, case #GenE.A!enumelt: bb1, case #GenE.B!enumelt: bb2, case #GenE.C!enumelt: bb3
|
|
switch_enum_addr %1 : $*GenE<T>, case #GenE.A!enumelt: bb1, case #GenE.B!enumelt: bb2, default bb3
|
|
|
|
bb1:
|
|
%4 = integer_literal $Builtin.Int32, 10
|
|
br bb4(%4 : $Builtin.Int32)
|
|
|
|
bb2:
|
|
%6 = integer_literal $Builtin.Int32, 20
|
|
br bb4(%6 : $Builtin.Int32)
|
|
|
|
bb3:
|
|
destroy_addr %1 : $*GenE<T>
|
|
%9 = integer_literal $Builtin.Int32, 30
|
|
br bb4(%9 : $Builtin.Int32)
|
|
|
|
bb4(%11 : $Builtin.Int32):
|
|
%12 = struct $Int32 (%11 : $Builtin.Int32)
|
|
dealloc_stack %1 : $*GenE<T>
|
|
destroy_addr %0 : $*GenE<T>
|
|
return %12 : $Int32
|
|
}
|
|
|
|
// CHECK-LABEL: sil @test_no_replace
|
|
sil @test_no_replace : $@convention(thin) (@inout E) -> Int32 {
|
|
bb0(%0 : $*E):
|
|
%1 = load %0 : $*E
|
|
// CHECK: switch_enum %1 : $E, case #E.A!enumelt: bb1, default bb2
|
|
switch_enum %1 : $E, case #E.A!enumelt: bb1, default bb2
|
|
|
|
bb1:
|
|
%3 = integer_literal $Builtin.Int32, 10
|
|
br bb3(%3 : $Builtin.Int32)
|
|
|
|
bb2:
|
|
%21 = function_ref @external_f : $@convention(thin) () -> ()
|
|
%22 = apply %21() : $@convention(thin) () -> ()
|
|
%5 = integer_literal $Builtin.Int32, 30
|
|
br bb3(%5 : $Builtin.Int32)
|
|
|
|
bb3(%7 : $Builtin.Int32):
|
|
%8 = struct $Int32 (%7 : $Builtin.Int32)
|
|
return %8 : $Int32
|
|
}
|
|
|