Skip to content

Commit 8fe25f7

Browse files
committed
[NFC] Remove CompilerInstance::setSILModule
The REPL was using the CompilerInstance to stash this parameter, then it would immediately move it into IRGen. Drop the setter and pass this data directly.
1 parent bd57f14 commit 8fe25f7

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,6 @@ class CompilerInstance {
484484
}
485485
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
486486

487-
/// Set the SIL module for this compilation instance.
488-
///
489-
/// The CompilerInstance takes ownership of the given SILModule object.
490-
void setSILModule(std::unique_ptr<SILModule> M);
491-
492487
SILModule *getSILModule() {
493488
return TheSILModule.get();
494489
}

include/swift/Immediate/Immediate.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
#ifndef SWIFT_IMMEDIATE_IMMEDIATE_H
1919
#define SWIFT_IMMEDIATE_IMMEDIATE_H
2020

21+
#include <memory>
2122
#include <string>
2223
#include <vector>
2324

2425
namespace swift {
2526
class CompilerInstance;
2627
class IRGenOptions;
2728
class SILOptions;
29+
class SILModule;
2830

2931
// Using LLVM containers to store command-line arguments turns out
3032
// to be a lose, because LLVM's execution engine demands this vector
@@ -37,7 +39,8 @@ namespace swift {
3739
///
3840
/// \return the result returned from main(), if execution succeeded
3941
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
40-
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts);
42+
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
43+
std::unique_ptr<SILModule> &&SM);
4144

4245
void runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
4346
bool ParseStdlib);

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,6 @@ void CompilerInstance::createSILModule() {
185185
Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule());
186186
}
187187

188-
void CompilerInstance::setSILModule(std::unique_ptr<SILModule> M) {
189-
TheSILModule = std::move(M);
190-
}
191-
192188
void CompilerInstance::recordPrimaryInputBuffer(unsigned BufID) {
193189
PrimaryBufferIDs.insert(BufID);
194190
}
@@ -618,7 +614,7 @@ std::unique_ptr<SILModule> CompilerInstance::takeSILModule() {
618614
return std::move(TheSILModule);
619615
}
620616

621-
ModuleDecl *CompilerInstance::getMainModule() {
617+
ModuleDecl *CompilerInstance::getMainModule() const {
622618
if (!MainModule) {
623619
Identifier ID = Context->getIdentifier(Invocation.getModuleName());
624620
MainModule = ModuleDecl::create(ID, *Context);

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ static void generateIR(const IRGenOptions &IRGenOpts,
13831383

13841384
static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invocation,
13851385
CompilerInstance &Instance,
1386-
std::unique_ptr<SILModule> SM,
1386+
std::unique_ptr<SILModule> &&SM,
13871387
ModuleOrSourceFile MSF,
13881388
FrontendObserver *observer,
13891389
int &ReturnValue) {
@@ -1392,8 +1392,6 @@ static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invoca
13921392
const IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
13931393
const ProcessCmdLine &CmdLine =
13941394
ProcessCmdLine(opts.ImmediateArgv.begin(), opts.ImmediateArgv.end());
1395-
Instance.setSILModule(std::move(SM));
1396-
13971395

13981396
PrettyStackTraceStringAction trace(
13991397
"running user code",

lib/Immediate/Immediate.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ bool swift::immediate::autolinkImportedModules(ModuleDecl *M,
237237
int swift::RunImmediately(CompilerInstance &CI,
238238
const ProcessCmdLine &CmdLine,
239239
const IRGenOptions &IRGenOpts,
240-
const SILOptions &SILOpts) {
240+
const SILOptions &SILOpts,
241+
std::unique_ptr<SILModule> &&SM) {
241242
ASTContext &Context = CI.getASTContext();
242243

243244
// IRGen the main module.
@@ -246,7 +247,7 @@ int swift::RunImmediately(CompilerInstance &CI,
246247
// FIXME: We shouldn't need to use the global context here, but
247248
// something is persisting across calls to performIRGeneration.
248249
auto ModuleOwner = performIRGeneration(
249-
IRGenOpts, swiftModule, CI.takeSILModule(), swiftModule->getName().str(),
250+
IRGenOpts, swiftModule, std::move(SM), swiftModule->getName().str(),
250251
PSPs, getGlobalLLVMContext(), ArrayRef<std::string>());
251252
auto *Module = ModuleOwner.get();
252253

0 commit comments

Comments
 (0)