Files
swift-mirror/test/embedded/classes-methods-no-stdlib.swift
Kuba Mracek d0c2a4ccf8 [embedded] Initial support for generic classes in embedded Swift
- VTableSpecializer, a new pass that synthesizes a new vtable per each observed concrete type used
- Don't use full type metadata refs in embedded Swift
- Lazily emit specialized class metadata (LazySpecializedClassMetadata) in IRGen
- Don't emit regular class metadata for a class decl if it's generic (only emit the specialized metadata)
2023-09-12 09:44:54 -07:00

37 lines
1.4 KiB
Swift

// RUN: %target-swift-emit-ir %s -parse-stdlib -enable-experimental-feature Embedded -target arm64e-apple-none | %FileCheck %s
public class MyClass {
func foo() { }
func bar() { }
}
public class MySubClass: MyClass {
override func foo() { }
}
// CHECK: @"$s4main7MyClassCN" = {{.*}}<{ ptr, ptr, ptr, ptr, ptr }> <{ ptr null, ptr @"$s4main7MyClassCfD", ptr @"$s4main7MyClassC3fooyyF", ptr @"$s4main7MyClassC3baryyF", ptr @"$s4main7MyClassCACycfC" }>
// CHECK: @"$s4main10MySubClassCN" = {{.*}}<{ ptr, ptr, ptr, ptr, ptr }> <{ ptr @"$s4main7MyClassCN", ptr @"$s4main10MySubClassCfD", ptr @"$s4main10MySubClassC3fooyyF", ptr @"$s4main7MyClassC3baryyF", ptr @"$s4main10MySubClassCACycfC" }>
// CHECK: define {{.*}}void @"$s4main4test1xyAA7MyClassC_tF"(ptr %0)
public func test(x: MyClass) {
x.foo() // goes through the vtable
// CHECK: %1 = load ptr, ptr %0
// CHECK: %2 = getelementptr inbounds ptr, ptr %1, i64 2
// CHECK: %3 = load ptr, ptr %2
// CHECK: call swiftcc void %3(ptr swiftself %0)
x.bar() // does not go through the vtable
// CHECK: call swiftcc void @"$s4main7MyClassC3baryyF"
let y = MySubClass()
// CHECK: call swiftcc ptr @"$s4main10MySubClassCACycfC"
y.foo() // does not go through the vtable
// CHECK: call swiftcc void @"$s4main10MySubClassC3fooyyF"
y.bar() // does not go through the vtable
// CHECK: call swiftcc void @"$s4main7MyClassC3baryyF"
}