mirror of
https://github.com/apple/swift.git
synced 2025-12-25 12:15:36 +01:00
In a previous commit, I banned in the verifier any SILValue from producing ValueOwnershipKind::Any in preparation for this. This change arises out of discussions in between John, Andy, and I around ValueOwnershipKind::Trivial. The specific realization was that this ownership kind was an unnecessary conflation of the a type system idea (triviality) with an ownership idea (@any, an ownership kind that is compatible with any other ownership kind at value merge points and can only create). This caused the ownership model to have to contort to handle the non-payloaded or trivial cases of non-trivial enums. This is unnecessary if we just eliminate the any case and in the verifier separately verify that trivial => @any (notice that we do not verify that @any => trivial). NOTE: This is technically an NFC intended change since I am just replacing Trivial with Any. That is why if you look at the tests you will see that I actually did not need to update anything except removing some @trivial ownership since @any ownership is represented without writing @any in the parsed sil. rdar://46294760
71 lines
3.0 KiB
Plaintext
71 lines
3.0 KiB
Plaintext
sil_stage raw // CHECK: sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import Foundation
|
|
|
|
protocol SomeProtocol { }
|
|
class SomeClass : SomeProtocol { }
|
|
|
|
// CHECK-LABEL: @objc_classes : $@convention(thin) (@thick NSObject.Type) -> ()
|
|
sil [transparent] [serialized] @objc_classes : $@convention(thin) (@thick NSObject.Type) -> () {
|
|
bb0(%0 : $@thick NSObject.Type):
|
|
%1 = thick_to_objc_metatype %0 : $@thick NSObject.Type to $@objc_metatype NSObject.Type
|
|
// CHECK: %2 = alloc_ref_dynamic [objc] %1 : $@objc_metatype NSObject.Type, $NSObject
|
|
%2 = alloc_ref_dynamic [objc] %1 : $@objc_metatype NSObject.Type, $NSObject
|
|
%3 = value_metatype $@thick NSObject.Type, %2 : $NSObject
|
|
dealloc_partial_ref %2 : $NSObject, %3 : $@thick NSObject.Type
|
|
|
|
%void = tuple ()
|
|
return %void : $()
|
|
} // CHECK: } // end sil function 'objc_classes'
|
|
|
|
class Bas : NSObject {
|
|
var strRealProp : String
|
|
override init()
|
|
}
|
|
|
|
sil [serialized] @test_super_method : $@convention(method) (@guaranteed Bas) -> Bas
|
|
sil [serialized] @swift_StringToNSString : $@convention(thin) (@inout String) -> @owned NSString
|
|
sil [serialized] @$sSSSSycSSmcfC : $@convention(thin) (@thin String.Type) -> @owned String
|
|
|
|
protocol SomeClassProtocol : class {}
|
|
|
|
// CHECK-LABEL: sil public_external [transparent] [serialized] @metatype_to_object
|
|
// CHECK: {{%.*}} = objc_metatype_to_object {{%.*}} : $@objc_metatype SomeClass.Type to $AnyObject
|
|
// CHECK: {{%.*}} = objc_existential_metatype_to_object {{%.*}} : $@objc_metatype SomeClassProtocol.Type to $AnyObject
|
|
sil [transparent] [serialized] @metatype_to_object : $@convention(thin) (@objc_metatype SomeClass.Type, @objc_metatype SomeClassProtocol.Type) -> @owned (AnyObject, AnyObject) {
|
|
entry(%a : $@objc_metatype SomeClass.Type, %b : $@objc_metatype SomeClassProtocol.Type):
|
|
%x = objc_metatype_to_object %a : $@objc_metatype SomeClass.Type to $AnyObject
|
|
%y = objc_existential_metatype_to_object %b : $@objc_metatype SomeClassProtocol.Type to $AnyObject
|
|
%z = tuple (%x : $AnyObject, %y : $AnyObject)
|
|
return %z : $(AnyObject, AnyObject)
|
|
}
|
|
|
|
@objc protocol ObjCProto {}
|
|
|
|
// CHECK-LABEL: sil public_external [transparent] [serialized] @protocol_conversion
|
|
sil [transparent] [serialized] @protocol_conversion : $@convention(thin) () -> @owned Protocol {
|
|
entry:
|
|
// CHECK: {{%.*}} = objc_protocol #ObjCProto : $Protocol
|
|
%p = objc_protocol #ObjCProto : $Protocol
|
|
return %p : $Protocol
|
|
}
|
|
|
|
@_transparent public func serialize_all() {
|
|
}
|
|
|
|
sil [transparent] [serialized] @$s14def_basic_objc13serialize_allyyF : $@convention(thin) () -> () {
|
|
bb0:
|
|
%26 = function_ref @objc_classes : $@convention(thin) (@thick NSObject.Type) -> ()
|
|
|
|
%79 = function_ref @test_super_method : $@convention(method) (@guaranteed Bas) -> Bas
|
|
|
|
%125 = function_ref @metatype_to_object : $@convention(thin) (@objc_metatype SomeClass.Type, @objc_metatype SomeClassProtocol.Type) -> @owned (AnyObject, AnyObject)
|
|
|
|
%126 = function_ref @protocol_conversion : $@convention(thin) () -> @owned Protocol
|
|
|
|
%119 = tuple ()
|
|
return %119 : $()
|
|
}
|