Skip to content

Remove -sil-link-all frontend flag #15830

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
merged 3 commits into from
Apr 9, 2018
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
3 changes: 0 additions & 3 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ def sil_unroll_threshold : Separate<["-"], "sil-unroll-threshold">,
def sil_merge_partial_modules : Flag<["-"], "sil-merge-partial-modules">,
HelpText<"Merge SIL from all partial swiftmodules into the final module">;

def sil_link_all : Flag<["-"], "sil-link-all">,
HelpText<"Link all SIL functions">;

def sil_verify_all : Flag<["-"], "sil-verify-all">,
HelpText<"Verify SIL after each transform">;

Expand Down
6 changes: 0 additions & 6 deletions include/swift/SIL/SILModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,6 @@ class SILModule {
/// i.e. it can be linked by linkFunction.
bool hasFunction(StringRef Name);

/// Link in all Witness Tables in the module.
void linkAllWitnessTables();

/// Link in all VTables in the module.
void linkAllVTables();

/// Link all definitions in all segments that are logically part of
/// the same AST module.
void linkAllFromCurrentModule();
Expand Down
7 changes: 0 additions & 7 deletions include/swift/SILOptimizer/PassManager/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ namespace swift {
/// \brief Remove dead functions from \p M.
void performSILDeadFunctionElimination(SILModule *M);

/// \brief Link a SILFunction declaration to the actual definition in the
/// serialized modules.
///
/// \param M the SILModule on which to operate
/// \param LinkAll when true, always link. For testing purposes.
void performSILLinking(SILModule *M, bool LinkAll = false);

/// \brief Convert SIL to a lowered form suitable for IRGen.
void runSILLoweringPasses(SILModule &M);

Expand Down
11 changes: 2 additions & 9 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
}
}

if (const Arg *A = Args.getLastArg(OPT_disable_sil_linking,
OPT_sil_link_all)) {
if (A->getOption().matches(OPT_disable_sil_linking))
Opts.LinkMode = SILOptions::LinkNone;
else if (A->getOption().matches(OPT_sil_link_all))
Opts.LinkMode = SILOptions::LinkAll;
else
llvm_unreachable("Unknown SIL linking option!");
}
if (const Arg *A = Args.getLastArg(OPT_disable_sil_linking))
Opts.LinkMode = SILOptions::LinkNone;

if (Args.hasArg(OPT_sil_merge_partial_modules))
Opts.MergePartialModules = true;
Expand Down
11 changes: 0 additions & 11 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,13 +980,6 @@ static bool performCompile(CompilerInstance &Instance,
return false;
}

/// If we are asked to link all, link all.
static void linkAllIfNeeded(const CompilerInvocation &Invocation,
SILModule *SM) {
if (Invocation.getSILOptions().LinkMode == SILOptions::LinkAll)
performSILLinking(SM, true);
}

/// Perform "stable" optimizations that are invariant across compiler versions.
static bool performMandatorySILPasses(CompilerInvocation &Invocation,
SILModule *SM,
Expand All @@ -1008,8 +1001,6 @@ static bool performMandatorySILPasses(CompilerInvocation &Invocation,
return true;
}

linkAllIfNeeded(Invocation, SM);

if (Invocation.getSILOptions().MergePartialModules)
SM->linkAllFromCurrentModule();
return false;
Expand Down Expand Up @@ -1211,12 +1202,10 @@ static bool performCompileStepsPostSILGen(

// We've been told to emit SIL after SILGen, so write it now.
if (Action == FrontendOptions::ActionType::EmitSILGen) {
linkAllIfNeeded(Invocation, SM.get());
return writeSIL(*SM, PSPs, Instance, Invocation);
}

if (Action == FrontendOptions::ActionType::EmitSIBGen) {
linkAllIfNeeded(Invocation, SM.get());
serializeSIB(SM.get(), PSPs, Instance.getASTContext(), MSF);
return Context.hadError();
}
Expand Down
1 change: 0 additions & 1 deletion lib/Immediate/Immediate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ bool swift::immediate::IRGenImportedModules(

std::unique_ptr<SILModule> SILMod = performSILGeneration(import,
CI.getSILOptions());
performSILLinking(SILMod.get());
if (runSILDiagnosticPasses(*SILMod)) {
hadError = true;
break;
Expand Down
1 change: 0 additions & 1 deletion lib/Immediate/REPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,6 @@ class REPLEnvironment {
if (!CI.getASTContext().hadError()) {
sil = performSILGeneration(REPLInputFile, CI.getSILOptions(),
RC.CurIRGenElem);
performSILLinking(sil.get());
runSILDiagnosticPasses(*sil);
runSILLoweringPasses(*sil);
}
Expand Down
8 changes: 0 additions & 8 deletions lib/SIL/SILModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,6 @@ void SILModule::linkAllFromCurrentModule() {
/*PrimaryFile=*/nullptr);
}

void SILModule::linkAllWitnessTables() {
getSILLoader()->getAllWitnessTables();
}

void SILModule::linkAllVTables() {
getSILLoader()->getAllVTables();
}

void SILModule::invalidateSILLoaderCaches() {
getSILLoader()->invalidateCaches();
}
Expand Down
15 changes: 5 additions & 10 deletions lib/SILOptimizer/Mandatory/MandatoryInlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,10 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
return false;
}

// Create our initial list of substitutions.
llvm::SmallVector<Substitution, 16> ApplySubs(InnerAI.subs_begin(),
InnerAI.subs_end());

// Then if we have a partial_apply, add any additional subsitutions that
// we may require to the end of the list.
if (PAI) {
copy(PAI->getSubstitutions(), std::back_inserter(ApplySubs));
}
// Get our list of substitutions.
auto Subs = (PAI
? PAI->getSubstitutions()
: InnerAI.getSubstitutions());

SILOpenedArchetypesTracker OpenedArchetypesTracker(F);
F->getModule().registerDeleteNotificationHandler(
Expand All @@ -555,7 +550,7 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
}

SILInliner Inliner(*F, *CalleeFunction,
SILInliner::InlineKind::MandatoryInline, ApplySubs,
SILInliner::InlineKind::MandatoryInline, Subs,
OpenedArchetypesTracker);
if (!Inliner.canInlineFunction(InnerAI)) {
// See comment above about casting when devirtualizing and how this
Expand Down
14 changes: 0 additions & 14 deletions lib/SILOptimizer/UtilityPasses/Link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ using namespace swift;
// Top Level Driver
//===----------------------------------------------------------------------===//

void swift::performSILLinking(SILModule *M, bool LinkAll) {
auto LinkMode = LinkAll? SILModule::LinkingMode::LinkAll :
SILModule::LinkingMode::LinkNormal;
for (auto &Fn : *M)
M->linkFunction(&Fn, LinkMode);

if (!LinkAll)
return;

M->linkAllWitnessTables();
M->linkAllVTables();
}


namespace {

/// Copies code from the standard library into the user program to enable
Expand Down
2 changes: 1 addition & 1 deletion test/SIL/Serialization/generic_shared_function.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/generic_shared_function_helper.sil -module-name SILSource
// RUN: %target-swift-frontend -emit-module -o %t -I %t -primary-file %s -module-name main -sil-link-all
// RUN: %target-swift-frontend -emit-module -o %t -I %t -primary-file %s -module-name main

// Just don't crash when using -primary-file and re-serializing a
// generic shared_external SIL function.
Expand Down
Loading