Skip to content

Commit 098a1c9

Browse files
committed
Stop importing SILModule.h in Frontend.h
...for no other reason than to slightly improve compile times when something changes in SILModule.h or SILFunction.h.
1 parent a9784c7 commit 098a1c9

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "swift/Migrator/MigratorOptions.h"
3535
#include "swift/Parse/CodeCompletionCallbacks.h"
3636
#include "swift/Parse/Parser.h"
37-
#include "swift/SIL/SILModule.h"
3837
#include "swift/Sema/SourceLoader.h"
3938
#include "swift/Serialization/Validation.h"
4039
#include "swift/Subsystems.h"
@@ -49,6 +48,7 @@
4948
namespace swift {
5049

5150
class SerializedModuleLoader;
51+
class SILModule;
5252

5353
/// The abstract configuration of the compiler, including:
5454
/// - options for all stages of translation,
@@ -371,6 +371,15 @@ class CompilerInstance {
371371
void createSILModule();
372372

373373
public:
374+
// Out of line to avoid having to import SILModule.h.
375+
CompilerInstance();
376+
~CompilerInstance();
377+
378+
CompilerInstance(const CompilerInstance &) = delete;
379+
void operator=(const CompilerInstance &) = delete;
380+
CompilerInstance(CompilerInstance &&) = delete;
381+
void operator=(CompilerInstance &&) = delete;
382+
374383
SourceManager &getSourceMgr() { return SourceMgr; }
375384

376385
DiagnosticEngine &getDiags() { return Diagnostics; }
@@ -398,9 +407,7 @@ class CompilerInstance {
398407
/// Set the SIL module for this compilation instance.
399408
///
400409
/// The CompilerInstance takes ownership of the given SILModule object.
401-
void setSILModule(std::unique_ptr<SILModule> M) {
402-
TheSILModule = std::move(M);
403-
}
410+
void setSILModule(std::unique_ptr<SILModule> M);
404411

405412
SILModule *getSILModule() {
406413
return TheSILModule.get();

lib/Frontend/Frontend.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737

3838
using namespace swift;
3939

40+
CompilerInstance::CompilerInstance() = default;
41+
CompilerInstance::~CompilerInstance() = default;
42+
4043
std::string CompilerInvocation::getPCHHash() const {
4144
using llvm::hash_code;
4245
using llvm::hash_value;
@@ -76,6 +79,10 @@ void CompilerInstance::createSILModule() {
7679
Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule());
7780
}
7881

82+
void CompilerInstance::setSILModule(std::unique_ptr<SILModule> M) {
83+
TheSILModule = std::move(M);
84+
}
85+
7986
void CompilerInstance::recordPrimaryInputBuffer(unsigned BufID) {
8087
PrimaryBufferIDs.insert(BufID);
8188
}

tools/driver/modulewrap_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
2323
#include "swift/Option/Options.h"
2424
#include "swift/Serialization/ModuleFormat.h"
25+
#include "swift/SIL/SILModule.h"
2526
#include "swift/Subsystems.h"
2627
#include "llvm/ADT/ArrayRef.h"
2728
#include "llvm/Bitcode/BitstreamReader.h"

0 commit comments

Comments
 (0)