mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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.
68 lines
2.8 KiB
Swift
68 lines
2.8 KiB
Swift
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -enable-sil-opaque-values -Xllvm -sil-full-demangle -enable-library-evolution %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
|
|
|
|
|
|
// CHECK-LABEL: sil [ossa] @$s30opaque_values_silgen_resilient10OneOfTheseO4hash4intoys6HasherVz_tF : {{.*}} {
|
|
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : $*Hasher, [[ENUM:%[^,]+]] : @guaranteed $OneOfThese):
|
|
// CHECK: switch_enum [[ENUM]] : $OneOfThese, case #OneOfThese.loadable!enumelt: [[LOADABLE:bb[0-9]+]], case #OneOfThese.resilient!enumelt: [[RESILIENT:bb[0-9]+]]
|
|
// CHECK: [[LOADABLE]]([[LOADABLE_BOX:%[^,]+]] :
|
|
// CHECK: [[LOADABLE_ADDR:%[^,]+]] = project_box [[LOADABLE_BOX]]
|
|
// CHECK: load_borrow [[LOADABLE_ADDR]] : $*OneOfThese.Loadable
|
|
// CHECK: [[RESILIENT]]([[RESILIENT_BOX:%[^,]+]] :
|
|
// CHECK: [[RESILIENT_ADDR:%[^,]+]] = project_box [[RESILIENT_BOX]]
|
|
// CHECK: load_borrow [[RESILIENT_ADDR]] : $*OneOfThese.Resilient
|
|
// CHECK-LABEL: } // end sil function '$s30opaque_values_silgen_resilient10OneOfTheseO4hash4intoys6HasherVz_tF'
|
|
|
|
@frozen
|
|
public indirect enum OneOfThese : Hashable {
|
|
@frozen
|
|
public struct Loadable : Hashable {
|
|
var o: AnyHashable
|
|
var i: Int
|
|
}
|
|
case loadable(Loadable)
|
|
public struct Resilient : Hashable {
|
|
var o: AnyHashable
|
|
var i: Int
|
|
}
|
|
case resilient(Resilient)
|
|
}
|
|
|
|
|
|
public protocol ProtocolWithAYield {
|
|
associatedtype Assoc
|
|
@_borrowed
|
|
subscript() -> Assoc { get }
|
|
}
|
|
|
|
public struct ResilientTrivialStruct {}
|
|
|
|
public struct StructYieldingAResilientTrivialValue : ProtocolWithAYield {
|
|
var i: ResilientTrivialStruct
|
|
public typealias Assoc = ResilientTrivialStruct
|
|
// CHECK-LABEL: sil {{.*}}@$s30opaque_values_silgen_resilient36StructYieldingAResilientTrivialValueVAA18ProtocolWithAYieldA2aDP5AssocQzycirTW {{.*}} {
|
|
// CHECK: yield {{%[^,]+}} : $ResilientTrivialStruct
|
|
// CHECK-LABEL: } // end sil function '$s30opaque_values_silgen_resilient36StructYieldingAResilientTrivialValueVAA18ProtocolWithAYieldA2aDP5AssocQzycirTW'
|
|
public subscript() -> ResilientTrivialStruct {
|
|
_read {
|
|
yield i
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct ResilientNontrivialStruct {
|
|
var s: String
|
|
}
|
|
|
|
public struct StructYieldingAResilientNonetrivialValue : ProtocolWithAYield {
|
|
var i: ResilientNontrivialStruct
|
|
public typealias Assoc = ResilientNontrivialStruct
|
|
// CHECK-LABEL: sil {{.*}}@$s30opaque_values_silgen_resilient40StructYieldingAResilientNonetrivialValueVAA18ProtocolWithAYieldA2aDP5AssocQzycirTW {{.*}} {
|
|
// CHECK: yield {{%[^,]+}} : $ResilientNontrivialStruct
|
|
// CHECK-LABEL: } // end sil function '$s30opaque_values_silgen_resilient40StructYieldingAResilientNonetrivialValueVAA18ProtocolWithAYieldA2aDP5AssocQzycirTW'
|
|
public subscript() -> ResilientNontrivialStruct {
|
|
_read {
|
|
yield i
|
|
}
|
|
}
|
|
}
|