blob: 9e1bb5586969416b9dd0f6ff132e4e26f56058a7 [file] [log] [blame]
// RUN: %target-swift-frontend -emit-ir %s | FileCheck %s
// REQUIRES: CPU=x86_64
sil_stage canonical
import Builtin
import Swift
class C {
required init()
}
sil @_TFC12dynamic_init1CCfMS0_FT_S0_ : $@convention(method) (@thick C.Type) -> @owned C
sil @_TFC12dynamic_init1CcfMS0_FT_S0_ : $@convention(method) (@owned C) -> @owned C
sil @_TFC12dynamic_init1Cd : $@convention(method) (@owned C) -> @owned Builtin.NativeObject
sil @_TFC12dynamic_init1CD : $@convention(method) (@owned C) -> ()
// CHECK-LABEL: define{{( protected)?}} void @_TF12dynamic_init15testDynamicInitFT2cmMCS_1C_T_
sil @_TF12dynamic_init15testDynamicInitFT2cmMCS_1C_T_ : $@convention(method) (@thick C.Type) -> () {
bb0(%0 : $@thick C.Type):
// CHECK: [[META:%[0-9]+]] = bitcast %swift.type* %0 to %C12dynamic_init1C* (%swift.type*)**
// CHECK: [[VTABLE_OFFSET:%[0-9]+]] = getelementptr inbounds %C12dynamic_init1C* (%swift.type*)*, %C12dynamic_init1C* (%swift.type*)** [[META]], i64 10
// CHECK: [[CTOR:%[0-9]+]] = load %C12dynamic_init1C* (%swift.type*)*, %C12dynamic_init1C* (%swift.type*)** [[VTABLE_OFFSET]], align 8
// CHECK: [[CTOR_I8:%[0-9]+]] = bitcast %C12dynamic_init1C* (%swift.type*)* [[CTOR]] to i8*
// CHECK: [[CTOR_FN:%[0-9]+]] = bitcast i8* [[CTOR_I8]] to %C12dynamic_init1C* (%swift.type*)*
%2 = class_method %0 : $@thick C.Type, #C.init!allocator.1 : (C.Type) -> () -> C , $@convention(method) (@thick C.Type) -> @owned C
// CHECK: [[RESULT:%[0-9]+]] = call %C12dynamic_init1C* [[CTOR_FN]](%swift.type* %0)
%3 = apply %2(%0) : $@convention(method) (@thick C.Type) -> @owned C
// CHECK: call void bitcast (void (%swift.refcounted*)* @rt_swift_release to void (%C12dynamic_init1C*)*)(%C12dynamic_init1C* [[RESULT]])
strong_release %3 : $C
// CHECK: ret void
%5 = tuple ()
return %5 : $()
}
sil_vtable C {
#C.init!allocator.1: _TFC12dynamic_init1CCfMS0_FT_S0_ // dynamic_init.C.__allocating_init (dynamic_init.C.Type)() -> dynamic_init.C
}