@@ -1837,7 +1837,7 @@ class SILGenModuleRAII {
1837
1837
}
1838
1838
}
1839
1839
1840
- SILGenModuleRAII (SILModule &M, ModuleDecl *SM ) : SGM{M, SM } {}
1840
+ explicit SILGenModuleRAII (SILModule &M) : SGM{M, M. getSwiftModule () } {}
1841
1841
1842
1842
~SILGenModuleRAII () {
1843
1843
// Emit any delayed definitions that were forced.
@@ -1860,70 +1860,49 @@ class SILGenModuleRAII {
1860
1860
} // end anonymous namespace
1861
1861
1862
1862
std::unique_ptr<SILModule>
1863
- SILGenSourceFileRequest ::evaluate (Evaluator &evaluator,
1864
- SILGenDescriptor desc) const {
1863
+ SILGenerationRequest ::evaluate (Evaluator &evaluator,
1864
+ SILGenDescriptor desc) const {
1865
1865
// If we have a .sil file to parse, defer to the parsing request.
1866
1866
if (desc.getSourceFileToParse ()) {
1867
1867
return llvm::cantFail (evaluator (ParseSILModuleRequest{desc}));
1868
1868
}
1869
1869
1870
- auto *unit = desc. context . get <FileUnit *>();
1871
- auto *mod = unit-> getParentModule ();
1872
- auto M = SILModule::createEmptyModule (desc. context , desc. conv , desc.opts );
1873
- SILGenModuleRAII scope (*M, mod );
1870
+ // Otherwise perform SIL generation of the passed SourceFiles.
1871
+ auto silMod = SILModule::createEmptyModule (desc. context , desc. conv ,
1872
+ desc.opts );
1873
+ SILGenModuleRAII scope (*silMod );
1874
1874
1875
- if (auto *file = dyn_cast<SourceFile>(unit)) {
1876
- scope.emitSourceFile (file);
1877
- } else if (auto *file = dyn_cast<SerializedASTFile>(unit)) {
1878
- if (file->isSIB ())
1879
- M->getSILLoader ()->getAllForModule (mod->getName (), file);
1880
- }
1881
-
1882
- return M;
1883
- }
1884
-
1885
- std::unique_ptr<SILModule>
1886
- SILGenWholeModuleRequest::evaluate (Evaluator &evaluator,
1887
- SILGenDescriptor desc) const {
1888
- // If we have a .sil file to parse, defer to the parsing request.
1889
- if (desc.getSourceFileToParse ()) {
1890
- return llvm::cantFail (evaluator (ParseSILModuleRequest{desc}));
1891
- }
1892
-
1893
- auto *mod = desc.context .get <ModuleDecl *>();
1894
- auto M = SILModule::createEmptyModule (desc.context , desc.conv , desc.opts );
1895
- SILGenModuleRAII scope (*M, mod);
1896
-
1897
- for (auto file : mod->getFiles ()) {
1875
+ for (auto file : desc.getFiles ()) {
1898
1876
if (auto *nextSF = dyn_cast<SourceFile>(file))
1899
1877
scope.emitSourceFile (nextSF);
1900
1878
}
1901
1879
1902
- // Also make sure to process any intermediate files that may contain SIL
1903
- bool hasSIB = std::any_of (mod->getFiles ().begin (),
1904
- mod->getFiles ().end (),
1905
- [](const FileUnit *File) -> bool {
1880
+ // Also make sure to process any intermediate files that may contain SIL.
1881
+ bool hasSIB = llvm::any_of (desc.getFiles (), [](const FileUnit *File) -> bool {
1906
1882
auto *SASTF = dyn_cast<SerializedASTFile>(File);
1907
1883
return SASTF && SASTF->isSIB ();
1908
1884
});
1909
- if (hasSIB)
1910
- M->getSILLoader ()->getAllForModule (mod->getName (), nullptr );
1885
+ if (hasSIB) {
1886
+ auto primary = desc.context .dyn_cast <FileUnit *>();
1887
+ silMod->getSILLoader ()->getAllForModule (silMod->getSwiftModule ()->getName (),
1888
+ primary);
1889
+ }
1911
1890
1912
- return M ;
1891
+ return silMod ;
1913
1892
}
1914
1893
1915
1894
std::unique_ptr<SILModule>
1916
1895
swift::performSILGeneration (ModuleDecl *mod, Lowering::TypeConverter &tc,
1917
1896
const SILOptions &options) {
1918
1897
auto desc = SILGenDescriptor::forWholeModule (mod, tc, options);
1919
1898
return llvm::cantFail (
1920
- mod->getASTContext ().evaluator (SILGenWholeModuleRequest {desc}));
1899
+ mod->getASTContext ().evaluator (SILGenerationRequest {desc}));
1921
1900
}
1922
1901
1923
1902
std::unique_ptr<SILModule>
1924
1903
swift::performSILGeneration (FileUnit &sf, Lowering::TypeConverter &tc,
1925
1904
const SILOptions &options) {
1926
1905
auto desc = SILGenDescriptor::forFile (sf, tc, options);
1927
1906
return llvm::cantFail (
1928
- sf.getASTContext ().evaluator (SILGenSourceFileRequest {desc}));
1907
+ sf.getASTContext ().evaluator (SILGenerationRequest {desc}));
1929
1908
}
0 commit comments