Skip to content

Commit add2219

Browse files
committed
[SILGen] Allow lazy type-checking
Remove the type-checking call from OptimizedIRRequest, and sink it down into SILGen and IRGen when we come to emit the source files.
1 parent b96eb1d commit add2219

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "swift/SIL/FormalLinkage.h"
3535
#include "swift/SIL/SILDebugScope.h"
3636
#include "swift/SIL/SILModule.h"
37+
#include "swift/Subsystems.h"
3738
#include "clang/AST/ASTContext.h"
3839
#include "clang/AST/DeclCXX.h"
3940
#include "clang/AST/GlobalDecl.h"
@@ -443,7 +444,10 @@ class PrettySynthesizedFileUnitEmission : public llvm::PrettyStackTraceEntry {
443444

444445
/// Emit all the top-level code in the source file.
445446
void IRGenModule::emitSourceFile(SourceFile &SF) {
446-
assert(SF.ASTStage == SourceFile::TypeChecked);
447+
// Type-check the file if we haven't already (this may be necessary for .sil
448+
// files, which don't get fully type-checked by parsing).
449+
performTypeChecking(SF);
450+
447451
PrettySourceFileEmission StackEntry(SF);
448452

449453
// Emit types and other global decls.

lib/IRGen/IRGen.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,12 +1447,6 @@ GeneratedModule OptimizedIRRequest::evaluate(Evaluator &evaluator,
14471447

14481448
bindExtensions(*parentMod);
14491449

1450-
// Type-check the files that need emitting.
1451-
for (auto *file : desc.getFiles()) {
1452-
if (auto *SF = dyn_cast<SourceFile>(file))
1453-
performTypeChecking(*SF);
1454-
}
1455-
14561450
if (ctx.hadError())
14571451
return GeneratedModule::null();
14581452

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,8 @@ class SILGenModuleRAII {
18841884

18851885
public:
18861886
void emitSourceFile(SourceFile *sf) {
1887-
assert(sf->ASTStage == SourceFile::TypeChecked);
1887+
// Type-check the file if we haven't already.
1888+
performTypeChecking(*sf);
18881889

18891890
SourceFileScope scope(SGM, sf);
18901891
for (Decl *D : sf->getTopLevelDecls()) {

0 commit comments

Comments
 (0)