Skip to content

Commit 16f6ca9

Browse files
committed
[embedded] Fix a compiler crash when using generic classes in -O/-Osize
1 parent 8cfcc24 commit 16f6ca9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,13 @@ SILPassPipelinePlan::getPerformancePassPipeline(const SILOptions &Options) {
967967
// Perform optimizations that specialize.
968968
addClosureSpecializePassPipeline(P);
969969

970+
// For embedded Swift: We need to re-run VTableSpecializer in case the
971+
// performance inliner and specializer ended up discovering new generic
972+
// classes.
973+
if (Options.EmbeddedSwift) {
974+
P.addVTableSpecializer();
975+
}
976+
970977
// Run another iteration of the SSA optimizations to optimize the
971978
// devirtualized inline caches and constants propagated into closures
972979
// (CapturePropagation).

test/embedded/osize-generics.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-emit-ir -Osize %s -enable-experimental-feature Embedded | %FileCheck %s
2+
3+
public func foo<T>(n: T) {
4+
bar(n: 42)
5+
}
6+
7+
private func bar<T>(n: T) {
8+
baz(n: 42)
9+
}
10+
11+
public func baz<T>(n: T) {
12+
let x: ContiguousArray<Int> = .init(repeating: 0, count: 1)
13+
}
14+
15+
// CHECK: define {{.*}}@main(

0 commit comments

Comments
 (0)