diff --git a/include/swift/AST/SILOptions.h b/include/swift/AST/SILOptions.h index 75e794074f8af..31344711acc8f 100644 --- a/include/swift/AST/SILOptions.h +++ b/include/swift/AST/SILOptions.h @@ -74,6 +74,10 @@ class SILOptions { /// Whether to dump verbose SIL with scope and location information. bool EmitVerboseSIL = false; + /// Should we sort SIL functions, vtables, witness tables, and global + /// variables by name when we print it out. This eases diffing of SIL files. + bool EmitSortedSIL = false; + /// Whether to stop the optimization pipeline after serializing SIL. bool StopOptimizationAfterSerialization = false; diff --git a/include/swift/Frontend/FrontendOptions.h b/include/swift/Frontend/FrontendOptions.h index 9f0ba7a212327..b68d805d9833d 100644 --- a/include/swift/Frontend/FrontendOptions.h +++ b/include/swift/Frontend/FrontendOptions.h @@ -207,10 +207,6 @@ class FrontendOptions { /// \see ResilienceStrategy::Resilient bool EnableLibraryEvolution = false; - /// Indicates that the frontend should emit "verbose" SIL - /// (if asked to emit SIL). - bool EmitVerboseSIL = false; - /// If set, this module is part of a mixed Objective-C/Swift framework, and /// the Objective-C half should implicitly be visible to the Swift sources. bool ImportUnderlyingModule = false; @@ -251,8 +247,10 @@ class FrontendOptions { /// exit. bool PrintTargetInfo = false; - /// Should we sort SIL functions, vtables, witness tables, and global - /// variables by name when we print it out. This eases diffing of SIL files. + /// See the \ref SILOptions.EmitVerboseSIL flag. + bool EmitVerboseSIL = false; + + /// See the \ref SILOptions.EmitSortedSIL flag. bool EmitSortedSIL = false; /// Indicates whether the dependency tracker should track system diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 9d861e5b12600..b8eb1b23b75e5 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -941,6 +941,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args, Opts.VerifyAll |= Args.hasArg(OPT_sil_verify_all); Opts.DebugSerialization |= Args.hasArg(OPT_sil_debug_serialization); Opts.EmitVerboseSIL |= Args.hasArg(OPT_emit_verbose_sil); + Opts.EmitSortedSIL |= Args.hasArg(OPT_emit_sorted_sil); Opts.PrintInstCounts |= Args.hasArg(OPT_print_inst_counts); if (const Arg *A = Args.getLastArg(OPT_external_pass_pipeline_filename)) Opts.ExternalPassPipelineFilename = A->getValue(); diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index 98ec4b7dabfc7..74b9114c458b8 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -510,8 +510,7 @@ static bool writeSIL(SILModule &SM, ModuleDecl *M, bool EmitVerboseSIL, static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs, const CompilerInstance &Instance, - const CompilerInvocation &Invocation) { - const FrontendOptions &opts = Invocation.getFrontendOptions(); + const SILOptions &opts) { return writeSIL(SM, Instance.getMainModule(), opts.EmitVerboseSIL, PSPs.OutputFilename, opts.EmitSortedSIL); } @@ -1509,7 +1508,7 @@ static bool performCompileStepsPostSILGen( // We've been told to emit SIL after SILGen, so write it now. if (Action == FrontendOptions::ActionType::EmitSILGen) { - return writeSIL(*SM, PSPs, Instance, Invocation); + return writeSIL(*SM, PSPs, Instance, Invocation.getSILOptions()); } if (Action == FrontendOptions::ActionType::EmitSIBGen) { @@ -1578,7 +1577,7 @@ static bool performCompileStepsPostSILGen( // We've been told to write canonical SIL, so write it now. if (Action == FrontendOptions::ActionType::EmitSIL) - return writeSIL(*SM, PSPs, Instance, Invocation); + return writeSIL(*SM, PSPs, Instance, Invocation.getSILOptions()); assert(Action >= FrontendOptions::ActionType::Immediate && "All actions not requiring IRGen must have been handled!");