Files
swift-mirror/test/SILOptimizer/dynamic_self_cast.sil
Nate Chandler e5d87f75a8 [SIL] Add source formal type to checked_cast_br.
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.
2023-07-27 15:04:15 -07:00

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>
}