Skip to content

Reapply "merge partial SIL modules" again #11995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,14 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
// serialized ASTs.
Arguments.push_back("-parse-as-library");

// Merge serialized SIL from partial modules.
Arguments.push_back("-sil-merge-partial-modules");

// Disable SIL optimization passes; we've already optimized the code in each
// partial mode.
Arguments.push_back("-disable-diagnostic-passes");
Arguments.push_back("-disable-sil-perf-optzns");

addCommonFrontendArgs(*this, context.OI, context.Output, context.Args,
Arguments);
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
Expand Down
9 changes: 8 additions & 1 deletion lib/SIL/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4516,13 +4516,20 @@ void SILModule::verify() const {
// Uniquing set to catch symbol name collisions.
llvm::StringSet<> symbolNames;

// When merging partial modules, we only link functions from the current
// module, without enabling "LinkAll" mode or running the SILLinker pass;
// in this case, we need to relax some of the checks.
bool SingleFunction = false;
if (getOptions().MergePartialModules)
SingleFunction = true;

// Check all functions.
for (const SILFunction &f : *this) {
if (!symbolNames.insert(f.getName()).second) {
llvm::errs() << "Symbol redefined: " << f.getName() << "!\n";
assert(false && "triggering standard assertion failure routine");
}
f.verify(/*SingleFunction=*/false);
f.verify(SingleFunction);
}

// Check all globals.
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CodeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ void swift::maybeAddAccessorsToVariable(VarDecl *var, TypeChecker &TC) {
getter->setAccess(var->getFormalAccess());

// Make a setter if the behavior property has one.
if (auto valueSetter = valueProp->getSetter()) {
if (valueProp->getSetter()) {
ParamDecl *newValueParam = nullptr;
setter = createSetterPrototype(var, newValueParam, TC);
if (mightBeMutating && valueProp->isSetterMutating())
Expand Down
9 changes: 9 additions & 0 deletions test/Frontend/sil-merge-partial-modules-stdlib.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -emit-module -primary-file %s -module-name test -o %t/partial.swiftmodule -O

// RUN: %target-swift-frontend -emit-module %t/partial.swiftmodule -module-name test -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -o %t/test.swiftmodule

public func makeMirror(object x: Any) -> Mirror {
return Mirror(reflecting: x)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %target-resilience-test-wmo
// RUN: %target-resilience-test
// REQUIRES: executable_test

// FIXME: shouldn't need -whole-module-optimization here; we need to fix the
// frontend to merge serialized SIL functions from different translation units

import StdlibUnittest
import function_change_transparent_body

Expand Down