Skip to content

Commit a835c6b

Browse files
committed
[embedded] -O and -Osize embedded runtime
1 parent 45c2dd7 commit a835c6b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/SILOptimizer/UtilityPasses/Link.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ class SILLinker : public SILModuleTransform {
3939

4040
// In embedded Swift, the stdlib contains all the runtime functions needed
4141
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
42-
if (M.getASTContext().LangOpts.hasFeature(Feature::Embedded) &&
43-
!M.isStdlibModule()) {
42+
if (M.getASTContext().LangOpts.hasFeature(Feature::Embedded)) {
4443
linkEmbeddedRuntimeFromStdlib();
4544
}
4645
}
@@ -61,6 +60,10 @@ class SILLinker : public SILModuleTransform {
6160

6261
void linkEmbeddedRuntimeFunctionByName(StringRef name) {
6362
SILModule &M = *getModule();
63+
64+
// Bail if runtime function is already loaded.
65+
if (M.lookUpFunction(name)) return;
66+
6467
SILFunction *Fn =
6568
M.getSILLoader()->lookupSILFunction(name, SILLinkage::PublicExternal);
6669
if (!Fn) return;

stdlib/public/core/EmbeddedRuntime.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,8 @@ public func swift_once(predicate: UnsafeMutablePointer<Int>, fn: (@convention(c)
125125
fn(context)
126126
}
127127
}
128+
129+
@_silgen_name("swift_deletedMethodError")
130+
public func swift_deletedMethodError() -> Never {
131+
Builtin.int_trap()
132+
}

test/embedded/runtime.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// 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
24

35
// REQUIRES: executable_test
46
// REQUIRES: optimized_stdlib

0 commit comments

Comments
 (0)