Skip to content

Commit 8510b92

Browse files
[NFC] Add an EmitSortedSIL member to SILOptions for consistency. (#29210)
It is a bit strange to have the FrontendOptions being used in writeSIL instead of SILOptions, so this PR fixes that.
1 parent c02b95e commit 8510b92

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ class SILOptions {
7474
/// Whether to dump verbose SIL with scope and location information.
7575
bool EmitVerboseSIL = false;
7676

77+
/// Should we sort SIL functions, vtables, witness tables, and global
78+
/// variables by name when we print it out. This eases diffing of SIL files.
79+
bool EmitSortedSIL = false;
80+
7781
/// Whether to stop the optimization pipeline after serializing SIL.
7882
bool StopOptimizationAfterSerialization = false;
7983

include/swift/Frontend/FrontendOptions.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ class FrontendOptions {
207207
/// \see ResilienceStrategy::Resilient
208208
bool EnableLibraryEvolution = false;
209209

210-
/// Indicates that the frontend should emit "verbose" SIL
211-
/// (if asked to emit SIL).
212-
bool EmitVerboseSIL = false;
213-
214210
/// If set, this module is part of a mixed Objective-C/Swift framework, and
215211
/// the Objective-C half should implicitly be visible to the Swift sources.
216212
bool ImportUnderlyingModule = false;
@@ -251,8 +247,10 @@ class FrontendOptions {
251247
/// exit.
252248
bool PrintTargetInfo = false;
253249

254-
/// Should we sort SIL functions, vtables, witness tables, and global
255-
/// variables by name when we print it out. This eases diffing of SIL files.
250+
/// See the \ref SILOptions.EmitVerboseSIL flag.
251+
bool EmitVerboseSIL = false;
252+
253+
/// See the \ref SILOptions.EmitSortedSIL flag.
256254
bool EmitSortedSIL = false;
257255

258256
/// Indicates whether the dependency tracker should track system

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
941941
Opts.VerifyAll |= Args.hasArg(OPT_sil_verify_all);
942942
Opts.DebugSerialization |= Args.hasArg(OPT_sil_debug_serialization);
943943
Opts.EmitVerboseSIL |= Args.hasArg(OPT_emit_verbose_sil);
944+
Opts.EmitSortedSIL |= Args.hasArg(OPT_emit_sorted_sil);
944945
Opts.PrintInstCounts |= Args.hasArg(OPT_print_inst_counts);
945946
if (const Arg *A = Args.getLastArg(OPT_external_pass_pipeline_filename))
946947
Opts.ExternalPassPipelineFilename = A->getValue();

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ static bool writeSIL(SILModule &SM, ModuleDecl *M, bool EmitVerboseSIL,
510510

511511
static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs,
512512
const CompilerInstance &Instance,
513-
const CompilerInvocation &Invocation) {
514-
const FrontendOptions &opts = Invocation.getFrontendOptions();
513+
const SILOptions &opts) {
515514
return writeSIL(SM, Instance.getMainModule(), opts.EmitVerboseSIL,
516515
PSPs.OutputFilename, opts.EmitSortedSIL);
517516
}
@@ -1509,7 +1508,7 @@ static bool performCompileStepsPostSILGen(
15091508

15101509
// We've been told to emit SIL after SILGen, so write it now.
15111510
if (Action == FrontendOptions::ActionType::EmitSILGen) {
1512-
return writeSIL(*SM, PSPs, Instance, Invocation);
1511+
return writeSIL(*SM, PSPs, Instance, Invocation.getSILOptions());
15131512
}
15141513

15151514
if (Action == FrontendOptions::ActionType::EmitSIBGen) {
@@ -1578,7 +1577,7 @@ static bool performCompileStepsPostSILGen(
15781577

15791578
// We've been told to write canonical SIL, so write it now.
15801579
if (Action == FrontendOptions::ActionType::EmitSIL)
1581-
return writeSIL(*SM, PSPs, Instance, Invocation);
1580+
return writeSIL(*SM, PSPs, Instance, Invocation.getSILOptions());
15821581

15831582
assert(Action >= FrontendOptions::ActionType::Immediate &&
15841583
"All actions not requiring IRGen must have been handled!");

0 commit comments

Comments
 (0)