Skip to content

Commit 406c005

Browse files
author
Harlan Haskins
committed
[ParseableInterfaces] Stop explicitly optimizing cached modules
Previously, we always optimized cached modules. Now, use the flag we're already preserving to optimize them. Fixes rdar://46358840
1 parent 48f3c45 commit 406c005

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Diff for: lib/Frontend/ParseableInterfaceModuleLoader.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,6 @@ class swift::ParseableInterfaceBuilder {
520520
return;
521521
}
522522

523-
// Optimize emitted modules. This has to happen after we parse arguments,
524-
// because parseSILOpts would override the current optimization mode.
525-
subInvocation.getSILOptions().OptMode = OptimizationMode::ForSpeed;
526-
527523
// Build the .swiftmodule; this is a _very_ abridged version of the logic
528524
// in performCompile in libFrontendTool, specialized, to just the one
529525
// module-serialization task we're trying to do here.

Diff for: test/ParseableInterface/optimization-level.swift

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t/Lib.swiftinterface %s -O
3+
// RUN: %target-swift-frontend -build-module-from-parseable-interface %t/Lib.swiftinterface -Xllvm -sil-print-pass-name -o /dev/null 2>&1 | %FileCheck --check-prefix OPT %s
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t/Lib.swiftinterface %s -Onone
7+
// RUN: %target-swift-frontend -build-module-from-parseable-interface %t/Lib.swiftinterface -Xllvm -sil-print-pass-name -o /dev/null 2>&1 | %FileCheck --check-prefix UNOPT %s
8+
9+
// This is a bit of an implementation detail, but we want to make sure
10+
// optimization passes don't run when compiling a .swiftinterface that was
11+
// generated with -Onone.
12+
13+
// OPT: EagerSpecializer
14+
// UNOPT-NOT: EagerSpecializer
15+
public func f() {}
16+

Diff for: test/SourceKit/InterfaceGen/gen_swift_module.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ func f(s : inout [Int]) {
3030
// Test we can generate the interface of a module loaded via a .swiftinterface file correctly
3131

3232
// RUN: %empty-directory(%t.mod)
33-
// RUN: %swift -emit-module -o /dev/null -emit-parseable-module-interface-path %t.mod/swift_mod.swiftinterface %S/Inputs/swift_mod.swift -parse-as-library
33+
// RUN: %swift -emit-module -o /dev/null -emit-parseable-module-interface-path %t.mod/swift_mod.swiftinterface -O %S/Inputs/swift_mod.swift -parse-as-library
3434
// RUN: %sourcekitd-test -req=interface-gen -module swift_mod -- -I %t.mod -module-cache-path %t.mod/mcp > %t.response
3535
// RUN: diff -u %s.from_swiftinterface.response %t.response

0 commit comments

Comments
 (0)