blob: 9024204d98cf4ba17c9f9b8291802fb6b0251c58 [file] [log] [blame]
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/chex.py < %s > %t/cf.sil
// RUN: %target-swift-frontend -enable-objc-interop -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 -check-prefix CHECK-%target-import-type -check-prefix CHECK-%target-import-type-%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: @"$sSo17CCRefrigeratorRefaN" = linkonce_odr hidden
// CHECK-DIRECT-SAME: constant
// CHECK-INDIRECT-SAME: global
// CHECK-SAME: <{ {{.*}} }> <{
// -- value witness table
// CHECK-DIRECT-SAME: i8** @"$sBOWV",
// CHECK-INDIRECT-SAME: i8** null,
// CHECK-SAME: [[INT]] 515, {{.*}}"$sSo17CCRefrigeratorRefaMn", [[TYPE]]* null, i8* null }>
// CHECK: [[MUTABLE_REFRIGERATOR_NAME:@.*]] = private constant [52 x i8] c"CCMutableRefrigerator\00NCCMutableRefrigeratorRef\00St\00\00"
// CHECK-64: @"$sSo24CCMutableRefrigeratorRefaMn" = linkonce_odr hidden constant
// -- is imported, foreign init, is class, is nonunique
// CHECK-64-SAME: <i32 0x0006_0010>
// CHECK-64-SAME: [[MUTABLE_REFRIGERATOR_NAME]]
// CHECK-64-SAME: @"$sSo24CCMutableRefrigeratorRefaMa"
// CHECK-64-SAME: @"$sSo24CCMutableRefrigeratorRefaMr"
// CHECK-64: @"$sSo24CCMutableRefrigeratorRefaN" = linkonce_odr hidden global <{ {{.*}} }> <{
// -- value witness table
// CHECK-DIRECT-64-SAME: i8** @"$sBOWV",
// CHECK-INDIRECT-64-SAME: i8** null,
// CHECK-64-SAME: i64 515, {{.*}}"$sSo24CCMutableRefrigeratorRefaMn", %swift.type* 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-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @call_generic
// CHECK-SAME: ([[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-LABEL: define linkonce_odr hidden swiftcc %swift.metadata_response @"$sSo17CCRefrigeratorRefaMa"(
// CHECK-32: call swiftcc %swift.metadata_response @swift_getForeignTypeMetadata([[INT]] %0, [[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$sSo17CCRefrigeratorRefaN" to i8*), [[INT]] 4) to [[TYPE]]*))
// CHECK-64: call swiftcc %swift.metadata_response @swift_getForeignTypeMetadata([[INT]] %0, [[TYPE]]* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @"$sSo17CCRefrigeratorRefaN" to i8*), [[INT]] 8) to [[TYPE]]*))
// CHECK-LABEL: define internal swiftcc %swift.metadata_response @"$sSo24CCMutableRefrigeratorRefaMr"(%swift.type*, i8*, i8**)
// CHECK: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$sSo17CCRefrigeratorRefaMa"([[INT]] 255)
// CHECK-NEXT: [[T1:%.*]] = extractvalue %swift.metadata_response [[T0]], 0
// CHECK-NEXT: extractvalue %swift.metadata_response [[T0]], 1
// CHECK-NEXT: [[T2:%.*]] = bitcast %swift.type* %0 to %swift.type**
// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[T2]], i32 2
// CHECK-NEXT: store %swift.type* [[T1]], %swift.type** [[T3]], align
// CHECK-NEXT: ret %swift.metadata_response zeroinitializer