Skip to content

Commit 141152c

Browse files
authored
Merge pull request #15830 from slavapestov/remove-sil-link-all
Remove -sil-link-all frontend flag
2 parents 2278694 + 81cf1d9 commit 141152c

23 files changed

+202
-304
lines changed

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ def sil_unroll_threshold : Separate<["-"], "sil-unroll-threshold">,
393393
def sil_merge_partial_modules : Flag<["-"], "sil-merge-partial-modules">,
394394
HelpText<"Merge SIL from all partial swiftmodules into the final module">;
395395

396-
def sil_link_all : Flag<["-"], "sil-link-all">,
397-
HelpText<"Link all SIL functions">;
398-
399396
def sil_verify_all : Flag<["-"], "sil-verify-all">,
400397
HelpText<"Verify SIL after each transform">;
401398

include/swift/SIL/SILModule.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,6 @@ class SILModule {
504504
/// i.e. it can be linked by linkFunction.
505505
bool hasFunction(StringRef Name);
506506

507-
/// Link in all Witness Tables in the module.
508-
void linkAllWitnessTables();
509-
510-
/// Link in all VTables in the module.
511-
void linkAllVTables();
512-
513507
/// Link all definitions in all segments that are logically part of
514508
/// the same AST module.
515509
void linkAllFromCurrentModule();

include/swift/SILOptimizer/PassManager/Passes.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ namespace swift {
5555
/// \brief Remove dead functions from \p M.
5656
void performSILDeadFunctionElimination(SILModule *M);
5757

58-
/// \brief Link a SILFunction declaration to the actual definition in the
59-
/// serialized modules.
60-
///
61-
/// \param M the SILModule on which to operate
62-
/// \param LinkAll when true, always link. For testing purposes.
63-
void performSILLinking(SILModule *M, bool LinkAll = false);
64-
6558
/// \brief Convert SIL to a lowered form suitable for IRGen.
6659
void runSILLoweringPasses(SILModule &M);
6760

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
576576
}
577577
}
578578

579-
if (const Arg *A = Args.getLastArg(OPT_disable_sil_linking,
580-
OPT_sil_link_all)) {
581-
if (A->getOption().matches(OPT_disable_sil_linking))
582-
Opts.LinkMode = SILOptions::LinkNone;
583-
else if (A->getOption().matches(OPT_sil_link_all))
584-
Opts.LinkMode = SILOptions::LinkAll;
585-
else
586-
llvm_unreachable("Unknown SIL linking option!");
587-
}
579+
if (const Arg *A = Args.getLastArg(OPT_disable_sil_linking))
580+
Opts.LinkMode = SILOptions::LinkNone;
588581

589582
if (Args.hasArg(OPT_sil_merge_partial_modules))
590583
Opts.MergePartialModules = true;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,6 @@ static bool performCompile(CompilerInstance &Instance,
980980
return false;
981981
}
982982

983-
/// If we are asked to link all, link all.
984-
static void linkAllIfNeeded(const CompilerInvocation &Invocation,
985-
SILModule *SM) {
986-
if (Invocation.getSILOptions().LinkMode == SILOptions::LinkAll)
987-
performSILLinking(SM, true);
988-
}
989-
990983
/// Perform "stable" optimizations that are invariant across compiler versions.
991984
static bool performMandatorySILPasses(CompilerInvocation &Invocation,
992985
SILModule *SM,
@@ -1008,8 +1001,6 @@ static bool performMandatorySILPasses(CompilerInvocation &Invocation,
10081001
return true;
10091002
}
10101003

1011-
linkAllIfNeeded(Invocation, SM);
1012-
10131004
if (Invocation.getSILOptions().MergePartialModules)
10141005
SM->linkAllFromCurrentModule();
10151006
return false;
@@ -1211,12 +1202,10 @@ static bool performCompileStepsPostSILGen(
12111202

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

12181208
if (Action == FrontendOptions::ActionType::EmitSIBGen) {
1219-
linkAllIfNeeded(Invocation, SM.get());
12201209
serializeSIB(SM.get(), PSPs, Instance.getASTContext(), MSF);
12211210
return Context.hadError();
12221211
}

lib/Immediate/Immediate.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ bool swift::immediate::IRGenImportedModules(
253253

254254
std::unique_ptr<SILModule> SILMod = performSILGeneration(import,
255255
CI.getSILOptions());
256-
performSILLinking(SILMod.get());
257256
if (runSILDiagnosticPasses(*SILMod)) {
258257
hadError = true;
259258
break;

lib/Immediate/REPL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,6 @@ class REPLEnvironment {
869869
if (!CI.getASTContext().hadError()) {
870870
sil = performSILGeneration(REPLInputFile, CI.getSILOptions(),
871871
RC.CurIRGenElem);
872-
performSILLinking(sil.get());
873872
runSILDiagnosticPasses(*sil);
874873
runSILLoweringPasses(*sil);
875874
}

lib/SIL/SILModule.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,6 @@ void SILModule::linkAllFromCurrentModule() {
561561
/*PrimaryFile=*/nullptr);
562562
}
563563

564-
void SILModule::linkAllWitnessTables() {
565-
getSILLoader()->getAllWitnessTables();
566-
}
567-
568-
void SILModule::linkAllVTables() {
569-
getSILLoader()->getAllVTables();
570-
}
571-
572564
void SILModule::invalidateSILLoaderCaches() {
573565
getSILLoader()->invalidateCaches();
574566
}

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,10 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
533533
return false;
534534
}
535535

536-
// Create our initial list of substitutions.
537-
llvm::SmallVector<Substitution, 16> ApplySubs(InnerAI.subs_begin(),
538-
InnerAI.subs_end());
539-
540-
// Then if we have a partial_apply, add any additional subsitutions that
541-
// we may require to the end of the list.
542-
if (PAI) {
543-
copy(PAI->getSubstitutions(), std::back_inserter(ApplySubs));
544-
}
536+
// Get our list of substitutions.
537+
auto Subs = (PAI
538+
? PAI->getSubstitutions()
539+
: InnerAI.getSubstitutions());
545540

546541
SILOpenedArchetypesTracker OpenedArchetypesTracker(F);
547542
F->getModule().registerDeleteNotificationHandler(
@@ -555,7 +550,7 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
555550
}
556551

557552
SILInliner Inliner(*F, *CalleeFunction,
558-
SILInliner::InlineKind::MandatoryInline, ApplySubs,
553+
SILInliner::InlineKind::MandatoryInline, Subs,
559554
OpenedArchetypesTracker);
560555
if (!Inliner.canInlineFunction(InnerAI)) {
561556
// See comment above about casting when devirtualizing and how this

lib/SILOptimizer/UtilityPasses/Link.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ using namespace swift;
2020
// Top Level Driver
2121
//===----------------------------------------------------------------------===//
2222

23-
void swift::performSILLinking(SILModule *M, bool LinkAll) {
24-
auto LinkMode = LinkAll? SILModule::LinkingMode::LinkAll :
25-
SILModule::LinkingMode::LinkNormal;
26-
for (auto &Fn : *M)
27-
M->linkFunction(&Fn, LinkMode);
28-
29-
if (!LinkAll)
30-
return;
31-
32-
M->linkAllWitnessTables();
33-
M->linkAllVTables();
34-
}
35-
36-
3723
namespace {
3824

3925
/// Copies code from the standard library into the user program to enable

test/SIL/Serialization/generic_shared_function.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/generic_shared_function_helper.sil -module-name SILSource
3-
// RUN: %target-swift-frontend -emit-module -o %t -I %t -primary-file %s -module-name main -sil-link-all
3+
// RUN: %target-swift-frontend -emit-module -o %t -I %t -primary-file %s -module-name main
44

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

0 commit comments

Comments
 (0)