[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.
This commit is contained in:
Robert Widmann
2020-01-11 22:00:48 -08:00
parent bd57f14661
commit 8fe25f7530
5 changed files with 9 additions and 16 deletions

View File

@@ -484,11 +484,6 @@ public:
}
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
/// Set the SIL module for this compilation instance.
///
/// The CompilerInstance takes ownership of the given SILModule object.
void setSILModule(std::unique_ptr<SILModule> M);
SILModule *getSILModule() {
return TheSILModule.get();
}

View File

@@ -18,6 +18,7 @@
#ifndef SWIFT_IMMEDIATE_IMMEDIATE_H
#define SWIFT_IMMEDIATE_IMMEDIATE_H
#include <memory>
#include <string>
#include <vector>
@@ -25,6 +26,7 @@ namespace swift {
class CompilerInstance;
class IRGenOptions;
class SILOptions;
class SILModule;
// Using LLVM containers to store command-line arguments turns out
// to be a lose, because LLVM's execution engine demands this vector
@@ -37,7 +39,8 @@ namespace swift {
///
/// \return the result returned from main(), if execution succeeded
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts);
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
std::unique_ptr<SILModule> &&SM);
void runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
bool ParseStdlib);

View File

@@ -185,10 +185,6 @@ void CompilerInstance::createSILModule() {
Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule());
}
void CompilerInstance::setSILModule(std::unique_ptr<SILModule> M) {
TheSILModule = std::move(M);
}
void CompilerInstance::recordPrimaryInputBuffer(unsigned BufID) {
PrimaryBufferIDs.insert(BufID);
}
@@ -618,7 +614,7 @@ std::unique_ptr<SILModule> CompilerInstance::takeSILModule() {
return std::move(TheSILModule);
}
ModuleDecl *CompilerInstance::getMainModule() {
ModuleDecl *CompilerInstance::getMainModule() const {
if (!MainModule) {
Identifier ID = Context->getIdentifier(Invocation.getModuleName());
MainModule = ModuleDecl::create(ID, *Context);

View File

@@ -1383,7 +1383,7 @@ static void generateIR(const IRGenOptions &IRGenOpts,
static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invocation,
CompilerInstance &Instance,
std::unique_ptr<SILModule> SM,
std::unique_ptr<SILModule> &&SM,
ModuleOrSourceFile MSF,
FrontendObserver *observer,
int &ReturnValue) {
@@ -1392,8 +1392,6 @@ static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invoca
const IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
const ProcessCmdLine &CmdLine =
ProcessCmdLine(opts.ImmediateArgv.begin(), opts.ImmediateArgv.end());
Instance.setSILModule(std::move(SM));
PrettyStackTraceStringAction trace(
"running user code",

View File

@@ -237,7 +237,8 @@ bool swift::immediate::autolinkImportedModules(ModuleDecl *M,
int swift::RunImmediately(CompilerInstance &CI,
const ProcessCmdLine &CmdLine,
const IRGenOptions &IRGenOpts,
const SILOptions &SILOpts) {
const SILOptions &SILOpts,
std::unique_ptr<SILModule> &&SM) {
ASTContext &Context = CI.getASTContext();
// IRGen the main module.
@@ -246,7 +247,7 @@ int swift::RunImmediately(CompilerInstance &CI,
// FIXME: We shouldn't need to use the global context here, but
// something is persisting across calls to performIRGeneration.
auto ModuleOwner = performIRGeneration(
IRGenOpts, swiftModule, CI.takeSILModule(), swiftModule->getName().str(),
IRGenOpts, swiftModule, std::move(SM), swiftModule->getName().str(),
PSPs, getGlobalLLVMContext(), ArrayRef<std::string>());
auto *Module = ModuleOwner.get();