mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
66 lines
2.2 KiB
Plaintext
66 lines
2.2 KiB
Plaintext
// RUN: %empty-directory(%t)
|
|
// RUN: %build-irgen-test-overlays
|
|
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s
|
|
|
|
// REQUIRES: CPU=x86_64
|
|
// REQUIRES: objc_interop
|
|
|
|
import Swift
|
|
import gizmo
|
|
|
|
//
|
|
// A pure Swift class. We can access its isa directly.
|
|
//
|
|
|
|
class Purebred {
|
|
func method() {}
|
|
}
|
|
sil_vtable Purebred {}
|
|
|
|
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @purebred_method(ptr %0) {{.*}} {
|
|
// CHECK: [[ISA:%.*]] = load ptr, ptr %0
|
|
// CHECK: getelementptr inbounds {{.*}} [[ISA]]
|
|
sil @purebred_method : $@convention(thin) (@owned Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
%m = class_method %0 : $Purebred, #Purebred.method : (Purebred) -> () -> (), $@convention(method) (@guaranteed Purebred) -> ()
|
|
%z = apply %m(%0) : $@convention(method) (@guaranteed Purebred) -> ()
|
|
return %z : $()
|
|
}
|
|
|
|
//
|
|
// A mixed Swift/ObjC class. We have to mask when reading its isa.
|
|
//
|
|
|
|
class Mongrel: Gizmo {
|
|
func method() {}
|
|
}
|
|
sil_vtable Mongrel {}
|
|
|
|
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @mongrel_method(ptr %0) {{.*}} {
|
|
// CHECK: [[T1:%.*]] = load i64, ptr %0, align 8
|
|
// CHECK-NEXT: [[T2:%.*]] = load i64, ptr @swift_isaMask, align 8
|
|
// CHECK-NEXT: [[T3:%.*]] = and i64 [[T1]], [[T2]]
|
|
// CHECK: [[ISA:%.*]] = inttoptr i64 [[T3]] to ptr
|
|
// CHECK: getelementptr inbounds {{.*}} [[ISA]]
|
|
sil @mongrel_method : $@convention(thin) (@owned Mongrel) -> () {
|
|
entry(%0 : $Mongrel):
|
|
%m = class_method %0 : $Mongrel, #Mongrel.method : (Mongrel) -> () -> (), $@convention(method) (@guaranteed Mongrel) -> ()
|
|
%z = apply %m(%0) : $@convention(method) (@guaranteed Mongrel) -> ()
|
|
return %z : $()
|
|
}
|
|
|
|
// ObjC stubs expected by ObjC metadata emission
|
|
|
|
sil private @$s18class_isa_pointers7MongrelC6methodyyFTo : $@convention(objc_method) (Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
unreachable
|
|
}
|
|
sil private @$s18class_isa_pointers7MongrelC7bellsOnACSgSi_tcfcTo : $@convention(objc_method) (Int, Purebred) -> () {
|
|
entry(%0 : $Int, %1 : $Purebred):
|
|
unreachable
|
|
}
|
|
sil private @$s18class_isa_pointers7MongrelCACycfcTo : $@convention(objc_method) (Purebred) -> () {
|
|
entry(%0 : $Purebred):
|
|
unreachable
|
|
}
|