Files
swift-mirror/test/IRGen/class_isa_pointers.sil
Michael Gottesman dfe65c20f1 [lit] Change all %target-swift-frontend invocations to verify ownership.
We are already doing this for most of the target-swift-frontend ones. In a
subsequent commit, I am going to remove the redundant ones.

NOTE: On Darwin, I have not enabled it on the %target-swift-frontend mock SDK
commands. I ran into an issue with one of the PrintAsObjC tests that I am still
tracking down. I would rather just get this turned on to prevent further
regressions.

I also updated a few tests that needed some small tweaks to pass
this. Specifically:

1. Some parser tests needed some extra ossa insts to pass the verifier. This
doesn't effect what they actually test.

2. IRGen tests that should never have processed ossa directly. Today, we are
working towards a world where IRGen never processes [ossa] directly. Instead we
lower first. If/when that changes, we should add back in specific [ossa] tests.

3. A singular SILOptimizer definite init test case where the ownership verifier
fails due to a case which DI already flags as illegal (we just crash earlier). I
am going to look into fixing that by putting in errors in the typechecker or in
SILGen (not sure yet). I changed it to use target-swiftc_driver which does not
have ownership verification enabled.
2019-03-12 20:17:20 -07:00

70 lines
2.6 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(%T18class_isa_pointers8PurebredC*) {{.*}} {
// CHECK: [[ISA_PTR:%.*]] = bitcast %T18class_isa_pointers8PurebredC* %0 to %swift.type**
// CHECK: [[ISA:%.*]] = load %swift.type*, %swift.type** [[ISA_PTR]]
// CHECK: [[VTABLE:%.*]] = bitcast %swift.type* [[ISA]]
// CHECK: getelementptr inbounds {{.*}} [[VTABLE]]
sil @purebred_method : $@convention(thin) (@owned Purebred) -> () {
entry(%0 : $Purebred):
%m = class_method %0 : $Purebred, #Purebred.method!1 : (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(%T18class_isa_pointers7MongrelC*) {{.*}} {
// CHECK: [[T0:%.*]] = bitcast {{.*}} %0 to i64*
// CHECK-NEXT: [[T1:%.*]] = load i64, i64* [[T0]], align 8
// CHECK-NEXT: [[T2:%.*]] = load i64, i64* @swift_isaMask, align 8
// CHECK-NEXT: [[T3:%.*]] = and i64 [[T1]], [[T2]]
// CHECK: [[ISA:%.*]] = inttoptr i64 [[T3]] to %swift.type*
// CHECK: [[VTABLE:%.*]] = bitcast %swift.type* [[ISA]]
// CHECK: getelementptr inbounds {{.*}} [[VTABLE]]
sil @mongrel_method : $@convention(thin) (@owned Mongrel) -> () {
entry(%0 : $Mongrel):
%m = class_method %0 : $Mongrel, #Mongrel.method!1 : (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
}