Merge pull request #65925 from cachemeifyoucan/eng/PR-swift-frontend-tweaks-for-caching

Cleanup some redundant dependencies and unnecessary works that prevent compiler caching.
This commit is contained in:
Steven Wu
2023-05-23 15:32:05 -07:00
committed by GitHub
6 changed files with 45 additions and 29 deletions

View File

@@ -369,12 +369,13 @@ static bool precompileBridgingHeader(const CompilerInstance &Instance) {
if (!PCHOutDir.empty()) {
// Create or validate a persistent PCH.
auto SwiftPCHHash = Invocation.getPCHHash();
auto PCH = clangImporter->getOrCreatePCH(ImporterOpts, SwiftPCHHash);
auto PCH = clangImporter->getOrCreatePCH(ImporterOpts, SwiftPCHHash,
/*cached=*/false);
return !PCH.has_value();
}
return clangImporter->emitBridgingPCH(
opts.InputsAndOutputs.getFilenameOfFirstInput(),
opts.InputsAndOutputs.getSingleOutputFilename());
opts.InputsAndOutputs.getSingleOutputFilename(), /*cached=*/false);
}
static bool precompileClangModule(const CompilerInstance &Instance) {
@@ -2072,6 +2073,11 @@ int swift::performFrontend(ArrayRef<const char *> Args,
auto finishDiagProcessing = [&](int retValue, bool verifierEnabled) -> int {
FinishDiagProcessingCheckRAII.CalledFinishDiagProcessing = true;
PDC.setSuppressOutput(false);
if (auto *CDP = Instance->getCachingDiagnosticsProcessor()) {
// Don't cache if build failed.
if (retValue)
CDP->endDiagnosticCapture();
}
bool diagnosticsError = Instance->getDiags().finishProcessing();
// If the verifier is enabled and did not encounter any verification errors,
// return 0 even if the compile failed. This behavior isn't ideal, but large