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

59 lines
2.0 KiB
Plaintext

// RUN: %target-sil-opt -enable-sil-verify-all %s -specdevirt -code-sinking | %FileCheck %s
// RUN: %target-sil-opt -enable-sil-verify-all %s -specdevirt -code-sinking -wmo | %FileCheck --check-prefix=CHECK-WMO %s
sil_stage canonical
import Builtin
import Swift
// Make sure we convert a class_method into a diamond control flow
// where one of the sides is a direct call to FOO::ping.
class Foo {
func ping()
}
class Bar : Foo {
}
sil @_TFC8testcase3Foo4pingfS0_FT_T_ : $@convention(method) (@guaranteed Foo) -> () {
bb0(%0 : $Foo):
%2 = tuple () // user: %3
return %2 : $() // id: %3
}
sil @_TFC8testcase3FoocfMS0_FT_S0_ : $@convention(method) (@owned Foo) -> @owned Foo {
bb0(%0 : $Foo):
return %0 : $Foo // id: %1
}
//CHECK-LABEL: @_TF8testcase7my_mainFCS_3FooT_
//CHECK: checked_cast_br [exact] Foo in %0 : $Foo to Foo
//CHECK: return
//CHECK: checked_cast_br [exact] Foo in %0 : $Foo to Bar
//CHECK: class_method
//CHECK-WMO-LABEL: @_TF8testcase7my_mainFCS_3FooT_
//CHECK-WMO: checked_cast_br [exact] Foo in %0 : $Foo to Foo
//CHECK-WMO: return
//CHECK-WMO: unchecked_ref_cast %0 : $Foo to $Bar
//CHECK-WMO: class_method
sil @_TF8testcase7my_mainFCS_3FooT_ : $@convention(thin) (@owned Foo) -> () {
bb0(%0 : $Foo):
%1 = class_method %0 : $Foo, #Foo.ping : (Foo) -> () -> () , $@convention(method) (@guaranteed Foo) -> () // user: %2
%2 = apply %1(%0) : $@convention(method) (@guaranteed Foo) -> ()
%3 = tuple () // user: %4
return %3 : $() // id: %4
}
sil_vtable Foo {
#Foo.ping: @_TFC8testcase3Foo4pingfS0_FT_T_ // testcase.Foo.ping (testcase.Foo)() -> ()
#Foo.init!initializer: @_TFC8testcase3FoocfMS0_FT_S0_ // testcase.Foo.init (testcase.Foo.Type)() -> testcase.Foo
}
sil_vtable Bar {
#Foo.ping: @_TFC8testcase3Foo4pingfS0_FT_T_ [inherited]
#Foo.init!initializer: @_TFC8testcase3FoocfMS0_FT_S0_ [inherited]
}