mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
It is necessary for opaque values where for casts that will newly start out as checked_cast_brs and be lowered to checked_cast_addr_brs, since the latter has the source formal type, IRGen relies on being able to access it, and there's no way in general to obtain the source formal type from the source lowered type.
47 lines
1.7 KiB
Plaintext
47 lines
1.7 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all -O %s | %FileCheck %s
|
|
|
|
sil_stage raw
|
|
|
|
import Swift
|
|
|
|
public class SelfCasts {
|
|
}
|
|
|
|
// CHECK-LABEL: sil @$dynamic_self_cast_1 : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned Optional<SelfCasts>
|
|
sil @$dynamic_self_cast_1 : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned Optional<SelfCasts> {
|
|
bb0(%0 : $SelfCasts, %1 : $@thick SelfCasts.Type):
|
|
strong_retain %0 : $SelfCasts
|
|
// CHECK: checked_cast_br
|
|
checked_cast_br SelfCasts in %0 : $SelfCasts to @dynamic_self SelfCasts, bb1, bb2
|
|
bb1(%7 : $SelfCasts):
|
|
%8 = enum $Optional<SelfCasts>, #Optional.some!enumelt, %7 : $SelfCasts
|
|
br bb3(%8 : $Optional<SelfCasts>)
|
|
|
|
bb2:
|
|
strong_release %0 : $SelfCasts
|
|
%11 = enum $Optional<SelfCasts>, #Optional.none!enumelt
|
|
br bb3(%11 : $Optional<SelfCasts>)
|
|
|
|
bb3(%13 : $Optional<SelfCasts>):
|
|
return %13 : $Optional<SelfCasts>
|
|
}
|
|
|
|
// CHECK-LABEL: sil {{.*}}@$dynamic_self_cast_2 : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned Optional<SelfCasts>
|
|
sil @$dynamic_self_cast_2 : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned Optional<SelfCasts> {
|
|
bb0(%0 : $SelfCasts, %1 : $@thick SelfCasts.Type):
|
|
strong_retain %0 : $SelfCasts
|
|
// CHECK-NOT: checked_cast_br
|
|
checked_cast_br SelfCasts in %0 : $SelfCasts to SelfCasts, bb1, bb2
|
|
bb1(%7 : $SelfCasts):
|
|
%8 = enum $Optional<SelfCasts>, #Optional.some!enumelt, %7 : $SelfCasts
|
|
br bb3(%8 : $Optional<SelfCasts>)
|
|
|
|
bb2:
|
|
strong_release %0 : $SelfCasts
|
|
%11 = enum $Optional<SelfCasts>, #Optional.none!enumelt
|
|
br bb3(%11 : $Optional<SelfCasts>)
|
|
|
|
bb3(%13 : $Optional<SelfCasts>):
|
|
return %13 : $Optional<SelfCasts>
|
|
}
|