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.
84 lines
4.3 KiB
Swift
84 lines
4.3 KiB
Swift
// RUN: %target-swift-frontend %s -Xllvm -sil-print-types -emit-sil -disable-availability-checking -O -o - | %FileCheck %s
|
|
|
|
public protocol P<T> {
|
|
associatedtype T
|
|
}
|
|
public protocol Q: P where T == Int {}
|
|
public struct X: Q {
|
|
public typealias T = Int
|
|
}
|
|
public struct Y<T>: P {}
|
|
extension Y: Q where T == Int {}
|
|
|
|
@_optimize(none)
|
|
func use<T>(_ t: T) {}
|
|
|
|
// CHECK-LABEL: sil @$s35cast_folding_parameterized_protocol23concrete_to_existentialyyAA1XV_AA1YVyxGAFySiGtlF : $@convention(thin) <T> (X, Y<T>, Y<Int>) -> ()
|
|
public func concrete_to_existential<T>(_ x: X, _ yt: Y<T>, _ yi: Y<Int>) {
|
|
// CHECK:{{%.*}} = init_existential_addr %6 : $*any P, $X
|
|
use(x as! any P)
|
|
// CHECK: unconditional_checked_cast_addr X in {{%.*}} : $*X to any P<T> in {{%.*}} : $*any P<T>
|
|
use(x as! any P<T>)
|
|
// CHECK: unconditional_checked_cast_addr X in {{%.*}} : $*X to any P<Int> in {{%.*}} : $*any P<Int>
|
|
use(x as! any P<Int>)
|
|
// CHECK: unconditional_checked_cast_addr X in {{%.*}} : $*X to any P<String> in {{%.*}} : $*any P<String>
|
|
use(x as! any P<String>)
|
|
// CHECK: {{%.*}} = init_existential_addr {{%.*}} : $*any Q, $X
|
|
use(x as! any Q)
|
|
|
|
// CHECK: {{%.*}} = init_existential_addr {{%.*}} : $*any P, $Y<T>
|
|
use(yt as! any P)
|
|
// CHECK: unconditional_checked_cast_addr Y<T> in {{%.*}} : $*Y<T> to any P<T> in {{%.*}} : $*any P<T>
|
|
use(yt as! any P<T>)
|
|
// CHECK: unconditional_checked_cast_addr Y<T> in {{%.*}} : $*Y<T> to any P<Int> in {{%.*}} : $*any P<Int>
|
|
use(yt as! any P<Int>)
|
|
// CHECK: unconditional_checked_cast_addr Y<T> in {{%.*}} : $*Y<T> to any P<String> in {{%.*}} : $*any P<String>
|
|
use(yt as! any P<String>)
|
|
// CHECK: unconditional_checked_cast_addr Y<T> in {{%.*}} : $*Y<T> to any Q in {{%.*}} : $*any Q
|
|
use(yt as! any Q)
|
|
|
|
// CHECK: {{%.*}} = init_existential_addr {{%.*}} : $*any P, $Y<Int>
|
|
use(yi as! any P)
|
|
// CHECK: unconditional_checked_cast_addr Y<Int> in {{%.*}} : $*Y<Int> to any P<T> in {{%.*}} : $*any P<T>
|
|
use(yi as! any P<T>)
|
|
// CHECK: unconditional_checked_cast_addr Y<Int> in {{%.*}} : $*Y<Int> to any P<Int> in {{%.*}} : $*any P<Int>
|
|
use(yi as! any P<Int>)
|
|
// CHECK: unconditional_checked_cast_addr Y<Int> in {{%.*}} : $*Y<Int> to any P<String> in {{%.*}} : $*any P<String>
|
|
use(yi as! any P<String>)
|
|
// CHECK: {{%.*}} = init_existential_addr {{%.*}} : $*any Q, $Y<Int>
|
|
use(yi as! any Q)
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s35cast_folding_parameterized_protocol23existential_to_concreteyyxm_AA1P_px1TRts_XPtlF : $@convention(thin) <T> (@thick T.Type, @in_guaranteed any P<T>) -> ()
|
|
public func existential_to_concrete<T>(_: T.Type, _ p: any P<T>) {
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to X in {{%.*}} : $*X
|
|
_ = p as! X
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to Y<T> in {{%.*}} : $*Y<T>
|
|
_ = p as! Y<T>
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to Y<Int> in {{%.*}} : $*Y<Int>
|
|
_ = p as! Y<Int>
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to Y<String> in {{%.*}} : $*Y<String>
|
|
_ = p as! Y<String>
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$s35cast_folding_parameterized_protocol015existential_to_E0yyAA1P_px1TRts_XP_AA1Q_ptlF : $@convention(thin) <T> (@in_guaranteed any P<T>, @in_guaranteed any Q) -> ()
|
|
public func existential_to_existential<T>(_ p: any P<T>, _ q: any Q) {
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to any Q in {{%.*}} : $*any Q
|
|
_ = p as! any Q
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to any P in {{%.*}} : $*any P
|
|
_ = p as! any P
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to any P<Int> in {{%.*}} : $*any P<Int>
|
|
_ = p as! any P<Int>
|
|
// CHECK: unconditional_checked_cast_addr any P<T> in {{%.*}} : $*any P<T> to any P<String> in {{%.*}} : $*any P<String>
|
|
_ = p as! any P<String>
|
|
|
|
// CHECK: unconditional_checked_cast_addr any Q in {{%.*}} : $*any Q to any P in {{%.*}} : $*any P
|
|
_ = q as! any P
|
|
// CHECK: unconditional_checked_cast_addr any Q in {{%.*}} : $*any Q to any P<T> in {{%.*}} : $*any P<T>
|
|
_ = q as! any P<T>
|
|
// CHECK: unconditional_checked_cast_addr any Q in {{%.*}} : $*any Q to any P<Int> in {{%.*}} : $*any P<Int>
|
|
_ = q as! any P<Int>
|
|
// CHECK: unconditional_checked_cast_addr any Q in {{%.*}} : $*any Q to any P<String> in {{%.*}} : $*any P<String>
|
|
_ = q as! any P<String>
|
|
}
|