File tree Expand file tree Collapse file tree 11 files changed +628
-493
lines changed
SILOptimizer/UtilityPasses Expand file tree Collapse file tree 11 files changed +628
-493
lines changed Original file line number Diff line number Diff line change @@ -521,9 +521,10 @@ class CompilerInstance {
521
521
Optional<unsigned > BufferID);
522
522
523
523
public:
524
- // / Frees up the ASTContext and SILModule objects that this instance is
525
- // / holding on.
526
- void freeContextAndSIL ();
524
+ void freeASTContext ();
525
+
526
+ // / Frees up the SILModule that this instance is holding on to.
527
+ void freeSILModule ();
527
528
528
529
private:
529
530
// / Load stdlib & return true if should continue, i.e. no error
Original file line number Diff line number Diff line change @@ -104,6 +104,8 @@ class FrontendInputsAndOutputs {
104
104
105
105
bool hasPrimaryInputs () const { return primaryInputCount () > 0 ; }
106
106
107
+ bool hasMultiplePrimaryInputs () const { return primaryInputCount () > 1 ; }
108
+
107
109
// / Fails an assertion if there is more than one primary input.
108
110
// / Used in situations where only one primary input can be handled
109
111
// / and where batch mode has not been implemented yet.
Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ class FrontendOptions {
282
282
// / Indicates whether the action will immediately run code.
283
283
static bool isActionImmediate (ActionType);
284
284
285
+ // / \return true if action only parses without doing other compilation steps.
286
+ static bool shouldActionOnlyParse (ActionType);
287
+
285
288
// / Return a hash code of any components from these options that should
286
289
// / contribute to a Swift Bridging PCH hash.
287
290
llvm::hash_code getPCHHashComponents () const {
Original file line number Diff line number Diff line change @@ -25,10 +25,11 @@ class CompilerInstance;
25
25
26
26
namespace migrator {
27
27
28
- // / Run the migrator on the compiler invocation's input file and emit a
29
- // / "replacement map" describing the requested changes to the source file.
30
- bool updateCodeAndEmitRemap (CompilerInstance *Instance,
31
- const CompilerInvocation &Invocation);
28
+ // / If needed, run the migrator on the compiler invocation's input file and emit
29
+ // / a "replacement map" describing the requested changes to the source file.
30
+ // / \return true on error.
31
+ bool updateCodeAndEmitRemapIfNeeded (CompilerInstance *Instance,
32
+ const CompilerInvocation &Invocation);
32
33
33
34
struct Migrator {
34
35
CompilerInstance *StartInstance;
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ namespace swift {
65
65
// / \brief Convert SIL to a lowered form suitable for IRGen.
66
66
void runSILLoweringPasses (SILModule &M);
67
67
68
- // / \brief Perform SIL Inst Count on M.
69
- void performSILInstCount (SILModule *M);
68
+ // / \brief Perform SIL Inst Count on M if needed .
69
+ void performSILInstCountIfNeeded (SILModule *M);
70
70
71
71
// / \brief Identifiers for all passes. Used to procedurally create passes from
72
72
// / lists of passes.
Original file line number Diff line number Diff line change @@ -813,12 +813,12 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals) {
813
813
" Loaded a module during parse-only" );
814
814
}
815
815
816
- void CompilerInstance::freeContextAndSIL () {
816
+ void CompilerInstance::freeASTContext () {
817
817
Context.reset ();
818
- TheSILModule.reset ();
819
818
MainModule = nullptr ;
820
819
SML = nullptr ;
821
820
PrimaryBufferIDs.clear ();
822
821
PrimarySourceFiles.clear ();
823
822
}
824
823
824
+ void CompilerInstance::freeSILModule () { TheSILModule.reset (); }
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ void FrontendInputsAndOutputs::forEachPrimaryInput(
100
100
}
101
101
102
102
void FrontendInputsAndOutputs::assertMustNotBeMoreThanOnePrimaryInput () const {
103
- assert (primaryInputCount () < 2 &&
103
+ assert (! hasMultiplePrimaryInputs () &&
104
104
" have not implemented >1 primary input yet" );
105
105
}
106
106
Original file line number Diff line number Diff line change @@ -94,6 +94,19 @@ bool FrontendOptions::isActionImmediate(ActionType action) {
94
94
llvm_unreachable (" Unknown ActionType" );
95
95
}
96
96
97
+ bool FrontendOptions::shouldActionOnlyParse (ActionType action) {
98
+ switch (action) {
99
+ case FrontendOptions::ActionType::Parse:
100
+ case FrontendOptions::ActionType::DumpParse:
101
+ case FrontendOptions::ActionType::EmitSyntax:
102
+ case FrontendOptions::ActionType::DumpInterfaceHash:
103
+ case FrontendOptions::ActionType::EmitImportedModules:
104
+ return true ;
105
+ default :
106
+ return false ;
107
+ }
108
+ }
109
+
97
110
void FrontendOptions::forAllOutputPaths (
98
111
const InputFile &input, std::function<void (const std::string &)> fn) const {
99
112
if (RequestedAction != FrontendOptions::ActionType::EmitModuleOnly &&
You can’t perform that action at this time.
0 commit comments