Skip to content

Commit

Permalink
[Frontend] Re-add FrontendObserver methods
Browse files Browse the repository at this point in the history
These observer methods were used by external clients. Since we no longer
have the granularity between diagnostics and optimization, they're
rolled into a new observer callback, `performedSILProcessing`.

This (effectively) reverts commit 7b43e1d.
  • Loading branch information
harlanhaskins committed May 20, 2019
1 parent 7963529 commit 23655e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/swift/FrontendTool/FrontendTool.h
Expand Up @@ -42,6 +42,19 @@ class FrontendObserver {

/// The frontend has configured the compiler instance.
virtual void configuredCompiler(CompilerInstance &instance);

/// The frontend has performed semantic analysis.
virtual void performedSemanticAnalysis(CompilerInstance &instance);

/// The frontend has performed basic SIL generation.
/// SIL diagnostic passes have not yet been applied.
virtual void performedSILGeneration(SILModule &module);

/// The frontend has executed the SIL optimization and diagnostics pipelines.
virtual void performedSILProcessing(SILModule &module);

// TODO: maybe enhance this interface to hear about IRGen and LLVM
// progress.
};

namespace frontend {
Expand Down
12 changes: 12 additions & 0 deletions lib/FrontendTool/FrontendTool.cpp
Expand Up @@ -1005,6 +1005,9 @@ static bool performCompile(CompilerInstance &Instance,
if (Action == FrontendOptions::ActionType::ResolveImports)
return Context.hadError();

if (observer)
observer->performedSemanticAnalysis(Instance);

if (Stats)
countStatsPostSema(*Stats, Instance);

Expand Down Expand Up @@ -1238,6 +1241,9 @@ static bool performCompileStepsPostSILGen(
if (auto *SF = MSF.dyn_cast<SourceFile *>())
ricd.emplace(*SF);

if (observer)
observer->performedSILGeneration(*SM);

if (Stats)
countStatsPostSILGen(*Stats, *SM);

Expand Down Expand Up @@ -1284,6 +1290,9 @@ static bool performCompileStepsPostSILGen(
if (Instance.performSILProcessing(SM.get(), Stats))
return true;

if (observer)
observer->performedSILProcessing(*SM);

emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance, Invocation,
moduleIsPublic);

Expand Down Expand Up @@ -1847,3 +1856,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,

void FrontendObserver::parsedArgs(CompilerInvocation &invocation) {}
void FrontendObserver::configuredCompiler(CompilerInstance &instance) {}
void FrontendObserver::performedSemanticAnalysis(CompilerInstance &instance) {}
void FrontendObserver::performedSILGeneration(SILModule &module) {}
void FrontendObserver::performedSILProcessing(SILModule &module) {}

0 comments on commit 23655e5

Please sign in to comment.