blob: 7916e58514bd43fe28c5eabc4c8e69197438861e [file] [log] [blame]
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/chex.py < %s > %t/cf.sil
// RUN: %target-swift-frontend -enable-objc-interop -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 -DINT=i%target-ptrsize
// REQUIRES: CPU=i386 || CPU=x86_64
// CHECK: [[TYPE:%swift.type]] = type
// CHECK: [[REFRIGERATOR:%TSo17CCRefrigeratorRefa]] = type
// CHECK: [[MUTABLE_REFRIGERATOR:%TSo24CCMutableRefrigeratorRefa]] = type
// CHECK: [[OBJC:%objc_object]] = type
// CHECK-32: @"$SSo17CCRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// 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: i64 0,
// CHECK-64-SAME: i8** @"$SBOWV", i64 16, {{.*}}"$SSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null, i8* null, i8* null }>
// 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 0x0006_0010>
// CHECK-64-SAME: [[MUTABLE_REFRIGERATOR_NAME]]
// CHECK-64: @"$SSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// CHECK-64-SAME: @initialize_metadata_CCMutableRefrigerator
// CHECK-64-SAME: i32 0,
// 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{{( dllexport)?}}{{( protected)?}} swiftcc void @call_generic([[REFRIGERATOR]]*, [[MUTABLE_REFRIGERATOR]]*) {{.*}} {
// CHECK: [[T0:%.*]] = bitcast [[REFRIGERATOR]]* %0 to [[OBJC]]*
// CHECK-NEXT: [[T1:%.*]] = call swiftcc %swift.metadata_response @"$SSo17CCRefrigeratorRefaMa"([[INT]] 0)
// CHECK-NEXT: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T2]])
// CHECK: [[T0:%.*]] = bitcast [[MUTABLE_REFRIGERATOR]]* %1 to [[OBJC]]*
// CHECK-NEXT: [[T1:%.*]] = call swiftcc %swift.metadata_response @"$SSo24CCMutableRefrigeratorRefaMa"([[INT]] 0)
// CHECK-NEXT: [[T2:%.*]] = extractvalue %swift.metadata_response [[T1]], 0
// CHECK-NEXT: call swiftcc void @generic_function([[OBJC]]* [[T0]], [[TYPE]]* [[T2]])
// CHECK-NEXT: ret void
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$SSo17CCRefrigeratorRefaMa"(
// CHECK-32: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i32 8) to [[TYPE]]*))
// CHECK-64: call [[TYPE]]* @swift_getForeignTypeMetadata([[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$SSo17CCRefrigeratorRefaN" to i8*), i64 16) 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]]