Skip to content

Commit 958bf8e

Browse files
committed
[Frontend] Move dependency verifier to end of pipeline
Allow the verification of dependencies before LLVM, allowing the freeing of the ASTContext.
1 parent 12ae72c commit 958bf8e

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,19 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
12701270
emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance);
12711271
}
12721272

1273+
// Verify reference dependencies of the current compilation job. Note this
1274+
// must be run *before* verifying diagnostics so that the former can be tested
1275+
// via the latter.
1276+
if (opts.EnableIncrementalDependencyVerifier) {
1277+
if (!Instance.getPrimarySourceFiles().empty()) {
1278+
swift::verifyDependencies(Instance.getSourceMgr(),
1279+
Instance.getPrimarySourceFiles());
1280+
} else {
1281+
swift::verifyDependencies(Instance.getSourceMgr(),
1282+
Instance.getMainModule()->getFiles());
1283+
}
1284+
}
1285+
12731286
// Emit dependencies and index data.
12741287
emitReferenceDependenciesForAllPrimaryInputsIfNeeded(Instance);
12751288
emitIndexData(Instance);
@@ -1555,12 +1568,6 @@ static void freeASTContextIfPossible(CompilerInstance &Instance) {
15551568
return;
15561569
}
15571570

1558-
// Verifying incremental dependencies relies on access to the Swift Module's
1559-
// source files.
1560-
if (opts.EnableIncrementalDependencyVerifier) {
1561-
return;
1562-
}
1563-
15641571
// If there are multiple primary inputs it is too soon to free
15651572
// the ASTContext, etc.. OTOH, if this compilation generates code for > 1
15661573
// primary input, then freeing it after processing the last primary is
@@ -2228,19 +2235,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
22282235
Invocation.getFrontendOptions().DumpAPIPath);
22292236
}
22302237

2231-
// Verify reference dependencies of the current compilation job *before*
2232-
// verifying diagnostics so that the former can be tested via the latter.
2233-
if (Invocation.getFrontendOptions().EnableIncrementalDependencyVerifier) {
2234-
if (!Instance->getPrimarySourceFiles().empty()) {
2235-
HadError |= swift::verifyDependencies(Instance->getSourceMgr(),
2236-
Instance->getPrimarySourceFiles());
2237-
} else {
2238-
HadError |= swift::verifyDependencies(
2239-
Instance->getSourceMgr(),
2240-
Instance->getMainModule()->getFiles());
2241-
}
2242-
}
2243-
22442238
if (verifierEnabled) {
22452239
DiagnosticEngine &diags = Instance->getDiags();
22462240
if (diags.hasFatalErrorOccurred() &&

0 commit comments

Comments
 (0)