blob: d52805cb7500c4e10b07ba832decb643a049c432 [file] [log] [blame]
// RUN: rm -rf %t && mkdir -p %t
// RUN: %utils/chex.py < %s > %t/cf.sil
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -sdk %S/Inputs %t/cf.sil -emit-ir -import-cf-types | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize %t/cf.sil
// REQUIRES: CPU=i386 || CPU=x86_64
// REQUIRES: objc_interop
// CHECK: [[TYPE:%swift.type]] = type
// CHECK: [[REFRIGERATOR:%TSo17CCRefrigeratorRefa]] = type
// CHECK: [[MUTABLE_REFRIGERATOR:%TSo24CCMutableRefrigeratorRefa]] = type
// CHECK: [[OBJC:%objc_object]] = type
// CHECK: [[REFRIGERATOR_NAME:@.*]] = private constant [23 x i8] c"So17CCRefrigeratorRefa\00"
// CHECK-32: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// CHECK-32-SAME: [[REFRIGERATOR_NAME]] to i32
// CHECK-32-SAME: i32 0,
// CHECK-32-SAME: i8** @"$SBOWV", i32 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
// CHECK-64: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// CHECK-64-SAME: i32 0,
// CHECK-64-SAME: i32 trunc {{.*}} [[REFRIGERATOR_NAME]] to i64
// CHECK-64-SAME: i64 0,
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
// CHECK: [[MUTABLE_REFRIGERATOR_MANGLED_NAME:@.*]] = private constant [30 x i8] c"So24CCMutableRefrigeratorRefa\00"
// CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [25 x i8] c"CCMutableRefrigeratorRef\00"
// CHECK-64: @"$SSo24CCMutableRefrigeratorRefaMn" = linkonce_odr hidden constant
// -- is imported C typedef, is class, is nonunique
// CHECK-64-SAME: <i32 0x1000_0010>
// CHECK-64-SAME: [[MUTABLE_REFRIGERATOR_NAME]]
// CHECK-64-SAME: @get_field_types_CCMutableRefrigerator
// CHECK-64: @"$SSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// CHECK-64-SAME: @initialize_metadata_CCMutableRefrigerator
// CHECK-64-SAME: i32 trunc {{.*}} [[MUTABLE_REFRIGERATOR_MANGLED_NAME]] to i64
// CHECK-64-SAME: i64 1,
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo24CCMutableRefrigeratorRefaMn", [[TYPE]]* bitcast{{.*}}@"$SSo17CCRefrigeratorRefaN{{.*}} to %swift.type*), i8* null, i8* null, i8* null }>
sil_stage canonical
import CoreCooling
import Swift
sil public_external @generic_function : $@convention(thin) <T where T : AnyObject> (@owned T) -> ()
sil @call_generic : $@convention(thin) (@owned CCRefrigerator, @owned CCMutableRefrigerator) -> () {
bb0(%0 : $CCRefrigerator, %1: $CCMutableRefrigerator):
%2 = function_ref @generic_function : $@convention(thin) _0_0 where τ_0_0 : AnyObject> (@owned τ_0_0) -> ()
%3 = apply %2<CCRefrigerator>(%0) : $@convention(thin) _0_0 where τ_0_0 : AnyObject> (@owned τ_0_0) -> ()
%4 = apply %2<CCMutableRefrigerator>(%1) : $@convention(thin) _0_0 where τ_0_0 : AnyObject> (@owned τ_0_0) -> ()
%5 = tuple ()
return %5 : $()
}
// CHECK: define{{( protected)?}} swiftcc void @call_generic([[REFRIGERATOR]]*, [[MUTABLE_REFRIGERATOR]]*) {{.*}} {
// CHECK: [[T0:%.*]] = bitcast [[REFRIGERATOR]]* %0 to [[OBJC]]*
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"()
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]])
// CHECK: [[T0:%.*]] = bitcast [[MUTABLE_REFRIGERATOR]]* %1 to [[OBJC]]*
// CHECK-NEXT: [[T1:%.*]] = call [[TYPE]]* @"$SSo24CCMutableRefrigeratorRefaMa"()
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T1]])
// CHECK-NEXT: ret void
// CHECK: define linkonce_odr hidden [[TYPE]]* @"$SSo17CCRefrigeratorRefaMa"()
// CHECK-32: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 12) to [[TYPE]]*))
// CHECK-64: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 24) to [[TYPE]]*))
// CHECK: define private void @initialize_metadata_CCMutableRefrigerator(%swift.type*)
// CHECK-64: [[T0:%.*]] = bitcast %swift.type* %0 to i8**
// CHECK-64: [[T1:%.*]] = getelementptr inbounds i8*, i8** [[T0]], i32 2
// CHECK-64: [[T2:%.*]] = bitcast i8** [[T1]] to %swift.type**
// CHECK-64: [[T3:%.*]] = load %swift.type*, %swift.type** [[T2]]
// CHECK-64: [[T4:%.*]] = call %swift.type* @swift_getForeignTypeMetadata(%swift.type* [[T3]])
// CHECK-64: store %swift.type* [[T4]], %swift.type** [[T2]]