Skip to content

Commit d3b40ae

Browse files
authored
Merge pull request swiftlang#15974 from slavapestov/remove-disable-sil-linking
SIL: Remove -disable-sil-linking frontend flag
2 parents c4121c7 + a3ab756 commit d3b40ae

File tree

9 files changed

+19
-85
lines changed

9 files changed

+19
-85
lines changed

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ class SILOptions {
4242
/// The number of threads for multi-threaded code generation.
4343
int NumThreads = 0;
4444

45-
enum LinkingMode {
46-
/// Skip SIL linking.
47-
LinkNone,
48-
49-
/// Perform normal SIL linking.
50-
LinkNormal,
51-
52-
/// Link all functions during SIL linking.
53-
LinkAll
54-
};
55-
56-
/// Controls how to perform SIL linking.
57-
LinkingMode LinkMode = LinkNormal;
58-
5945
/// Controls whether to pull in SIL from partial modules during the
6046
/// merge modules step. Could perhaps be merged with the link mode
6147
/// above but the interactions between all the flags are tricky.

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ def stack_promotion_limit : Separate<["-"], "stack-promotion-limit">,
243243
HelpText<"Limit the size of stack promoted objects to the provided number "
244244
"of bytes.">;
245245

246-
def disable_sil_linking : Flag<["-"], "disable-sil-linking">,
247-
HelpText<"Don't link SIL functions">;
248-
249246
def dump_clang_diagnostics : Flag<["-"], "dump-clang-diagnostics">,
250247
HelpText<"Dump Clang diagnostics to stderr">;
251248

include/swift/SIL/SILModule.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,15 @@ class SILModule {
110110
using DefaultWitnessTableListType = llvm::ilist<SILDefaultWitnessTable>;
111111
using CoverageMapCollectionType =
112112
llvm::MapVector<StringRef, SILCoverageMap *>;
113-
using LinkingMode = SILOptions::LinkingMode;
113+
114+
enum class LinkingMode : uint8_t {
115+
/// Link functions with non-public linkage. Used by the mandatory pipeline.
116+
LinkNormal,
117+
118+
/// Link all functions. Used by the performance pipeine.
119+
LinkAll
120+
};
121+
114122
using ActionCallback = std::function<void()>;
115123

116124
private:
@@ -499,7 +507,7 @@ class SILModule {
499507
///
500508
/// \return false if the linking failed.
501509
bool linkFunction(SILFunction *F,
502-
LinkingMode LinkAll = LinkingMode::LinkNormal);
510+
LinkingMode LinkMode = LinkingMode::LinkNormal);
503511

504512
/// Check if a given function exists in any of the modules with a
505513
/// required linkage, i.e. it can be linked by linkFunction.

lib/Frontend/CompilerInvocation.cpp

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

579-
if (const Arg *A = Args.getLastArg(OPT_disable_sil_linking))
580-
Opts.LinkMode = SILOptions::LinkNone;
581-
582579
if (Args.hasArg(OPT_sil_merge_partial_modules))
583580
Opts.MergePartialModules = true;
584581

lib/SIL/Linker.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ void SILLinkerVisitor::maybeAddFunctionToWorklist(SILFunction *F) {
114114

115115
/// Process F, recursively deserializing any thing F may reference.
116116
bool SILLinkerVisitor::processFunction(SILFunction *F) {
117-
if (Mode == LinkingMode::LinkNone)
118-
return false;
119-
120117
// If F is a declaration, first deserialize it.
121118
if (F->isExternalDeclaration()) {
122119
maybeAddFunctionToWorklist(F);

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ static void collectPartiallyAppliedArguments(
259259
static SILFunction *getCalleeFunction(
260260
SILFunction *F, FullApplySite AI, bool &IsThick,
261261
SmallVectorImpl<std::pair<SILValue, ParameterConvention>> &CaptureArgs,
262-
SmallVectorImpl<SILValue> &FullArgs, PartialApplyInst *&PartialApply,
263-
SILModule::LinkingMode Mode) {
262+
SmallVectorImpl<SILValue> &FullArgs, PartialApplyInst *&PartialApply) {
264263
IsThick = false;
265264
PartialApply = nullptr;
266265
CaptureArgs.clear();
@@ -410,11 +409,8 @@ static SILFunction *getCalleeFunction(
410409
return nullptr;
411410

412411
// If CalleeFunction is a declaration, see if we can load it.
413-
if (CalleeFunction->empty()) {
414-
// FIXME: Remove 'Mode'
415-
if (Mode != SILOptions::LinkingMode::LinkNone)
416-
AI.getModule().loadFunction(CalleeFunction);
417-
}
412+
if (CalleeFunction->empty())
413+
AI.getModule().loadFunction(CalleeFunction);
418414

419415
// If we fail to load it, bail.
420416
if (CalleeFunction->empty())
@@ -467,7 +463,6 @@ tryDevirtualizeApplyHelper(FullApplySite InnerAI, SILBasicBlock::iterator I,
467463
/// \returns true if successful, false if failed due to circular inlining.
468464
static bool
469465
runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
470-
SILModule::LinkingMode Mode,
471466
DenseFunctionSet &FullyInlinedSet,
472467
ImmutableFunctionSet::Factory &SetFactory,
473468
ImmutableFunctionSet CurrentInliningSet,
@@ -515,13 +510,13 @@ runOnFunctionRecursively(SILFunction *F, FullApplySite AI,
515510
bool IsThick;
516511
PartialApplyInst *PAI;
517512
SILFunction *CalleeFunction = getCalleeFunction(
518-
F, InnerAI, IsThick, CaptureArgs, FullArgs, PAI, Mode);
513+
F, InnerAI, IsThick, CaptureArgs, FullArgs, PAI);
519514

520515
if (!CalleeFunction)
521516
continue;
522517

523518
// Then recursively process it first before trying to inline it.
524-
if (!runOnFunctionRecursively(CalleeFunction, InnerAI, Mode,
519+
if (!runOnFunctionRecursively(CalleeFunction, InnerAI,
525520
FullyInlinedSet, SetFactory,
526521
CurrentInliningSet, CHA)) {
527522
// If we failed due to circular inlining, then emit some notes to
@@ -630,7 +625,6 @@ class MandatoryInlining : public SILModuleTransform {
630625
void run() override {
631626
ClassHierarchyAnalysis *CHA = getAnalysis<ClassHierarchyAnalysis>();
632627
SILModule *M = getModule();
633-
SILModule::LinkingMode Mode = getOptions().LinkMode;
634628
bool ShouldCleanup = !getOptions().DebugSerialization;
635629
DenseFunctionSet FullyInlinedSet;
636630
ImmutableFunctionSet::Factory SetFactory;
@@ -645,9 +639,8 @@ class MandatoryInlining : public SILModuleTransform {
645639
continue;
646640

647641
runOnFunctionRecursively(&F,
648-
FullApplySite(static_cast<ApplyInst*>(nullptr)),
649-
Mode, FullyInlinedSet,
650-
SetFactory, SetFactory.getEmptySet(), CHA);
642+
FullApplySite(), FullyInlinedSet, SetFactory,
643+
SetFactory.getEmptySet(), CHA);
651644
}
652645

653646
if (!ShouldCleanup)

test/DebugInfo/LinetableArtificialFn.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

test/DebugInfo/basic.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
// --------------------------------------------------------------------
2121
// Now check that we do generate line+scope info with -g.
2222
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
23-
// RUN: %target-swift-frontend %s -emit-ir -g -o - -disable-sil-linking \
24-
// RUN: | %FileCheck %s --check-prefix=CHECK-NOSIL
2523
// --------------------------------------------------------------------
2624
// Currently -gdwarf-types should give the same results as -g.
2725
// RUN: %target-swift-frontend %s -emit-ir -gdwarf-types -o - | %FileCheck %s
@@ -49,10 +47,7 @@ func foo(_ a: Int64, _ b: Int64) -> Int64 {
4947
// CHECK-DAG: !DILexicalBlock({{.*}} line: [[@LINE-1]]
5048
// Transparent inlined multiply:
5149
// CHECK-DAG: smul{{.*}}, !dbg ![[MUL:[0-9]+]]
52-
// CHECK-DAG: [[MUL]] = !DILocation(line: [[@LINE+4]], column: 16,
53-
// Runtime call to multiply function:
54-
// CHECK-NOSIL: @"$Ss5Int64V1moiyA2B_ABtFZ{{.*}}, !dbg ![[MUL:[0-9]+]]
55-
// CHECK-NOSIL: [[MUL]] = !DILocation(line: [[@LINE+1]], column: 16,
50+
// CHECK-DAG: [[MUL]] = !DILocation(line: [[@LINE+1]], column: 16,
5651
return a*b
5752
} else {
5853
// CHECK-DAG: ![[PARENT:[0-9]+]] = distinct !DILexicalBlock({{.*}} line: [[@LINE-1]], column: 13)

test/SILOptimizer/capture_promotion_ownership.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// RUN: %target-swift-frontend %s -enable-sil-ownership -disable-sil-linking -emit-sil -o - | %FileCheck %s
2-
3-
// NOTE: We add -disable-sil-linking to the compile line to ensure that we have
4-
// access to declarations for standard library types, but not definitions. This
5-
// ensures that we are able to safely use standard library types for this test
6-
// without needing the standard library to be ownership correct in its body.
1+
// RUN: %target-swift-frontend %s -enable-sil-ownership -emit-sil -o - | %FileCheck %s
72

83
class Foo {
94
func foo() -> Int {

0 commit comments

Comments
 (0)