Skip to content

Commit c0b1526

Browse files
committed
[embedded] Avoid changing lookupStdlibFunction, load findStringSwitchCaseWithCache in MPO instead
1 parent 92b0c5f commit c0b1526

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ modu
8686
// eagerly linking and specializing _findStringSwitchCaseWithCache whenever findStringSwitchCase is found in the module.
8787
if context.options.enableEmbeddedSwift {
8888
if function.hasSemanticsAttribute("findStringSwitchCase"),
89-
let f = context.lookupStdlibFunction(name: "_findStringSwitchCaseWithCache") {
89+
let f = context.lookupStdlibFunction(name: "_findStringSwitchCaseWithCache"),
90+
context.loadFunction(function: f, loadCalleesRecursively: true) {
9091
worklist.pushIfNotVisited(f)
9192
}
9293
}

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,11 +1929,7 @@ OptionalBridgedFunction BridgedPassContext::lookupStdlibFunction(BridgedStringRe
19291929

19301930
SILDeclRef declRef(decl, SILDeclRef::Kind::Func);
19311931
SILOptFunctionBuilder funcBuilder(*invocation->getTransform());
1932-
SILFunction *function = funcBuilder.getOrCreateFunction(SILLocation(decl), declRef, NotForDefinition);
1933-
if (mod->getOptions().EmbeddedSwift) {
1934-
mod->linkFunction(function, SILModule::LinkingMode::LinkAll);
1935-
}
1936-
return {function};
1932+
return {funcBuilder.getOrCreateFunction(SILLocation(decl), declRef, NotForDefinition)};
19371933
}
19381934

19391935
OptionalBridgedFunction BridgedPassContext::lookUpNominalDeinitFunction(BridgedDeclObj nominal) const {

stdlib/public/core/StringSwitch.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ internal struct _StringSwitchContext {
6262
/// The \p cases array must not change between subsequent calls with the
6363
/// same \p cache.
6464
@_semantics("findStringSwitchCaseWithCache")
65+
@_used
6566
public // COMPILER_INTRINSIC
6667
func _findStringSwitchCaseWithCache(
6768
cases: [StaticString],

0 commit comments

Comments
 (0)