Skip to content

Commit

Permalink
[SILGen] Allow lazy type-checking
Browse files Browse the repository at this point in the history
Remove the type-checking call from
OptimizedIRRequest, and sink it down into SILGen
and IRGen when we come to emit the source files.
  • Loading branch information
hamishknight committed Sep 15, 2020
1 parent b96eb1d commit add2219
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 5 additions & 1 deletion lib/IRGen/GenDecl.cpp
Expand Up @@ -34,6 +34,7 @@
#include "swift/SIL/FormalLinkage.h"
#include "swift/SIL/SILDebugScope.h"
#include "swift/SIL/SILModule.h"
#include "swift/Subsystems.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/GlobalDecl.h"
Expand Down Expand Up @@ -443,7 +444,10 @@ class PrettySynthesizedFileUnitEmission : public llvm::PrettyStackTraceEntry {

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

PrettySourceFileEmission StackEntry(SF);

// Emit types and other global decls.
Expand Down
6 changes: 0 additions & 6 deletions lib/IRGen/IRGen.cpp
Expand Up @@ -1447,12 +1447,6 @@ GeneratedModule OptimizedIRRequest::evaluate(Evaluator &evaluator,

bindExtensions(*parentMod);

// Type-check the files that need emitting.
for (auto *file : desc.getFiles()) {
if (auto *SF = dyn_cast<SourceFile>(file))
performTypeChecking(*SF);
}

if (ctx.hadError())
return GeneratedModule::null();

Expand Down
3 changes: 2 additions & 1 deletion lib/SILGen/SILGen.cpp
Expand Up @@ -1884,7 +1884,8 @@ class SILGenModuleRAII {

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

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

0 comments on commit add2219

Please sign in to comment.