Skip to content

Commit 4d52b58

Browse files
authored
Merge pull request #74480 from kubamracek/embedded-no-eager-specializer
[embedded] Skip EagerSpecializer on embedded Swift
2 parents dd71e3d + b0f3da6 commit 4d52b58

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/SILOptimizer/PassManager/PassPipeline.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,14 @@ static void addPerfEarlyModulePassPipeline(SILPassPipelinePlan &P) {
683683
static void addHighLevelFunctionPipeline(SILPassPipelinePlan &P) {
684684
P.startPipeline("HighLevel,Function+EarlyLoopOpt",
685685
true /*isFunctionPassPipeline*/);
686-
P.addEagerSpecializer();
686+
687+
// Skip EagerSpecializer on embedded Swift, which already specializes
688+
// everything. Otherwise this would create metatype references for functions
689+
// with @_specialize attribute and those are incompatible with Emebdded Swift.
690+
if (!P.getOptions().EmbeddedSwift) {
691+
P.addEagerSpecializer();
692+
}
693+
687694
P.addObjCBridgingOptimization();
688695

689696
addFunctionPasses(P, OptimizationLevelKind::HighLevel);

test/embedded/specialize-attrs2.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-run-simple-swift(-parse-as-library -Onone -enable-experimental-feature Embedded -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop -Xlinker -dead_strip) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-parse-as-library -O -enable-experimental-feature Embedded -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop -Xlinker -dead_strip) | %FileCheck %s
3+
// RUN: %target-run-simple-swift(-parse-as-library -Osize -enable-experimental-feature Embedded -runtime-compatibility-version none -wmo -Xfrontend -disable-objc-interop -Xlinker -dead_strip) | %FileCheck %s
4+
5+
// REQUIRES: swift_in_compiler
6+
// REQUIRES: executable_test
7+
// REQUIRES: optimized_stdlib
8+
// REQUIRES: OS=macosx
9+
10+
@main
11+
struct Main {
12+
static func main() {
13+
let chars: [Character] = ["a", "b", "c"]
14+
let s = Substring.init(chars)
15+
print(s)
16+
print("OK!")
17+
}
18+
}
19+
20+
// CHECK: OK!

0 commit comments

Comments
 (0)