Files
swift-mirror/test/SILOptimizer/inlinecaches_arc.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

45 lines
1.3 KiB
Plaintext

// RUN: %target-sil-opt -enable-sil-verify-all %s -specdevirt -code-sinking -emit-sorted-sil | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
class Foo {
func ping() -> Int
}
sil @_TFC4main3Foo4pingfS0_FT_Si : $@convention(method) (@guaranteed Foo) -> Int
sil @_TFC4main3FoocfMS0_FT_S0_ : $@convention(method) (@owned Foo) -> @owned Foo
// CHECK-LABEL: _TF4main7my_mainFCS_3FooSi
// CHECK: bb0
// CHECK-NOT: strong_retain
// CHECK: checked_cast_br [exact] Foo in %0 : $Foo to Foo
// CHECK: bb1
// CHECK: class_method
// CHECK-NEXT: apply
// CHECK: strong_release
// CHECK: bb2
// CHECK: function_ref
// CHECK: apply
// CHECK: strong_release
// CHECK: bb3
// CHECK-NOT: strong_release
sil @_TF4main7my_mainFCS_3FooSi : $@convention(thin) (@owned Foo) -> Int {
bb0(%0 : $Foo):
debug_value %0 : $Foo, let, name "x" // id: %1
%3 = class_method %0 : $Foo, #Foo.ping : (Foo) -> () -> Int, $@convention(method) (@guaranteed Foo) -> Int // user: %4
%4 = apply %3(%0) : $@convention(method) (@guaranteed Foo) -> Int // user: %6
strong_release %0 : $Foo // id: %5
return %4 : $Int // id: %6
}
sil_vtable Foo {
#Foo.ping: @_TFC4main3Foo4pingfS0_FT_Si // main.Foo.ping (main.Foo)() -> Swift.Int
#Foo.init!initializer: @_TFC4main3FoocfMS0_FT_S0_ // main.Foo.init (main.Foo.Type)() -> main.Foo
}