Skip to content

Commit 11d8f70

Browse files
committed
Trigger SIL parsing from performSILGeneration
Rather than eagerly parsing an input .sil file in `performSemaUpTo`, trigger it from `performSILGeneration`. This will allow us to remove the SILModule stored on the CompilerInstance and will eventually allow the various SIL tools to just call into `performSILGeneration` without needing to call `performSema`.
1 parent fcb1dca commit 11d8f70

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,6 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
814814

815815
forEachFileToTypeCheck([&](SourceFile &SF) {
816816
performTypeChecking(SF);
817-
818-
// Parse the SIL decls if needed.
819-
// TODO: Requestify SIL parsing.
820-
if (TheSILModule) {
821-
SILParserState SILContext(TheSILModule.get());
822-
parseSourceFileSIL(SF, &SILContext);
823-
}
824817
});
825818

826819
finishTypeChecking();

lib/FrontendTool/FrontendTool.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,17 +1066,11 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
10661066
static bool performCompileStepsPostSema(CompilerInstance &Instance,
10671067
int &ReturnValue,
10681068
FrontendObserver *observer) {
1069-
auto mod = Instance.getMainModule();
1070-
if (auto SM = Instance.takeSILModule()) {
1071-
const PrimarySpecificPaths PSPs =
1072-
Instance.getPrimarySpecificPathsForAtMostOnePrimary();
1073-
return performCompileStepsPostSILGen(Instance, std::move(SM), mod, PSPs,
1074-
ReturnValue, observer);
1075-
}
1076-
10771069
const auto &Invocation = Instance.getInvocation();
10781070
const SILOptions &SILOpts = Invocation.getSILOptions();
10791071
const FrontendOptions &opts = Invocation.getFrontendOptions();
1072+
1073+
auto *mod = Instance.getMainModule();
10801074
if (!opts.InputsAndOutputs.hasPrimaryInputs()) {
10811075
// If there are no primary inputs the compiler is in WMO mode and builds one
10821076
// SILModule for the entire module.

lib/SILGen/SILGen.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,11 @@ class SILGenModuleRAII {
18601860
std::unique_ptr<SILModule>
18611861
SILGenSourceFileRequest::evaluate(Evaluator &evaluator,
18621862
SILGenDescriptor desc) const {
1863+
// If we have a .sil file to parse, defer to the parsing request.
1864+
if (desc.getSourceFileToParse()) {
1865+
return llvm::cantFail(evaluator(ParseSILModuleRequest{desc}));
1866+
}
1867+
18631868
auto *unit = desc.context.get<FileUnit *>();
18641869
auto *mod = unit->getParentModule();
18651870
auto M = std::unique_ptr<SILModule>(
@@ -1879,6 +1884,11 @@ SILGenSourceFileRequest::evaluate(Evaluator &evaluator,
18791884
std::unique_ptr<SILModule>
18801885
SILGenWholeModuleRequest::evaluate(Evaluator &evaluator,
18811886
SILGenDescriptor desc) const {
1887+
// If we have a .sil file to parse, defer to the parsing request.
1888+
if (desc.getSourceFileToParse()) {
1889+
return llvm::cantFail(evaluator(ParseSILModuleRequest{desc}));
1890+
}
1891+
18821892
auto *mod = desc.context.get<ModuleDecl *>();
18831893
auto M = std::unique_ptr<SILModule>(
18841894
new SILModule(mod, desc.conv, desc.opts, mod, /*wholeModule*/ true));

0 commit comments

Comments
 (0)