Skip to content

Commit d1979bb

Browse files
authored
Merge pull request #69186 from kubamracek/embedded-link-vtables
[embedded] When linking SIL vtables, also link superclass vtables
2 parents 278eba5 + 57c2636 commit d1979bb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/SIL/IR/Linker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ void SILLinkerVisitor::linkInVTable(ClassDecl *D) {
189189
maybeAddFunctionToWorklist(impl, Vtbl->isSerialized());
190190
}
191191
}
192+
193+
if (auto *S = D->getSuperclassDecl()) {
194+
linkInVTable(S);
195+
}
192196
}
193197

194198
//===----------------------------------------------------------------------===//
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-run-simple-swift(-enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-O -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
3+
// RUN: %target-run-simple-swift(-Osize -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop) | %FileCheck %s
4+
5+
// REQUIRES: executable_test
6+
// REQUIRES: optimized_stdlib
7+
// REQUIRES: VENDOR=apple
8+
// REQUIRES: OS=macosx
9+
10+
@main
11+
struct Main {
12+
static func main() {
13+
StaticString("Hello, World!").asUTF8Array.print()
14+
// CHECK: Hello, World!
15+
}
16+
}
17+
18+
extension StaticString {
19+
var asUTF8Array: [UInt8] {
20+
Array(UnsafeBufferPointer(start: utf8Start, count: utf8CodeUnitCount))
21+
}
22+
}
23+
24+
@_silgen_name("putchar")
25+
func putchar(_: UInt8)
26+
27+
extension Array<UInt8> {
28+
func print() {
29+
for byte in self {
30+
putchar(byte)
31+
}
32+
putchar(10)
33+
}
34+
}

0 commit comments

Comments
 (0)