1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
// RUN: %target-swift-frontend -primary-file %s -emit-ir -enable-objc-interop | %FileCheck %s --check-prefixes=CHECK,CHECK-objc
// RUN: %target-swift-frontend -primary-file %s -emit-ir -disable-objc-interop | %FileCheck %s --check-prefixes=CHECK,CHECK-native
// REQUIRES: CPU=x86_64
sil_stage canonical
import Builtin
import Swift
class A<T> {
}
sil_vtable A {}
protocol P {
func operate()
}
class B<T, U:P> {}
sil_vtable B {}
// CHECK-LABEL: define hidden swiftcc void @thick_metatype(ptr %0)
sil hidden @thick_metatype : $@convention(thin) <T> (@thick A<T>.Type) -> () {
bb0(%0 : $@thick A<T>.Type):
%2 = tuple ()
return %2 : $()
}
sil hidden_external @use_all : $@convention(thin) <T, U where T : P, U : P> () -> ()
// CHECK-LABEL: define hidden swiftcc void @class_pointer(ptr %0, ptr %T.P)
// CHECK: [[METADATA:%.*]] = load ptr, ptr %0, align 8
// CHECK-objc-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 10
// CHECK-native-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 7
// CHECK-NEXT: %T = load ptr, ptr [[T1]], align 8
// CHECK: store
// CHECK-objc-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 11
// CHECK-native-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 8
// CHECK-NEXT: %U = load ptr, ptr [[T1]], align 8
// CHECK: store
// CHECK-objc-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 12
// CHECK-native-NEXT: [[T1:%.*]] = getelementptr inbounds ptr, ptr [[METADATA]], i64 9
// CHECK-NEXT: %U.P = load ptr, ptr [[T1]], align 8
sil hidden @class_pointer : $@convention(thin) <T, U where T : P, U : P> (@guaranteed B<T, U>) -> () {
bb0(%0 : $B<T, U>):
%f = function_ref @use_all : $@convention(thin) <T, U where T : P, U : P> () -> ()
apply %f<T, U>() : $@convention(thin) <T, U where T : P, U : P> () -> ()
%3 = tuple ()
return %3 : $()
}
// CHECK-LABEL: define hidden swiftcc void @test_23121786(ptr %0, ptr %1)
sil hidden @test_23121786 : $@convention(thin) <T> (@owned A<A<T>>, @owned A<T>) -> () {
bb0(%0 : $A<A<T>>, %1 : $A<T>):
%2 = tuple ()
return %2 : $()
}
protocol A2 {
associatedtype AssocTy
}
protocol C {
}
extension A2 where Self.AssocTy : C {
}
class K<T> : A2 where T : C {
typealias AssocTy = T
}
sil @callee : $@convention(method) <τ_0_0 where τ_0_0 : A2, τ_0_0.AssocTy : C> (@in_guaranteed τ_0_0) -> ()
// CHECK-LABEL: define{{.*}} swiftcc void @caller(ptr {{.*}}, ptr %Self, ptr %SelfWitnessTable)
// CHECK: entry:
// CHECK-objc: %1 = getelementptr inbounds ptr, ptr %Self, i64 11
// CHECK-native: %1 = getelementptr inbounds ptr, ptr %Self, i64 8
// CHECK: %"\CF\84_1_0.C" = load ptr, ptr %1
// CHECK: call swiftcc void @callee(ptr %Self, ptr %SelfWitnessTable, ptr %"\CF\84_1_0.C"
sil @caller : $@convention(witness_method: A2) <τ_0_0><τ_1_0 where τ_0_0 : K<τ_1_0>, τ_1_0 : C> (@in_guaranteed τ_0_0) -> () {
bb0(%0 : $*τ_0_0):
%1 = function_ref @callee : $@convention(method) <τ_0_0 where τ_0_0 : A2, τ_0_0.AssocTy : C> (@in_guaranteed τ_0_0) -> ()
%2 = apply %1<τ_0_0>(%0) : $@convention(method) <τ_0_0 where τ_0_0 : A2, τ_0_0.AssocTy : C> (@in_guaranteed τ_0_0) -> ()
%3 = tuple ()
return %3 : $()
}
|