Skip to content

Commit 56e1fee

Browse files
Merge pull request #73305 from cachemeifyoucan/eng/PR-127062609-swift-6.0
[6.0][Caching] Add fast swift instance setup for cache replay
2 parents 717c341 + cfe87ec commit 56e1fee

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ class CompilerInstance {
691691
bool setup(const CompilerInvocation &Invocation, std::string &Error,
692692
ArrayRef<const char *> Args = {});
693693

694+
/// The fast setup function for cache replay.
695+
bool setupForReplay(const CompilerInvocation &Invocation, std::string &Error,
696+
ArrayRef<const char *> Args = {});
697+
694698
const CompilerInvocation &getInvocation() const { return Invocation; }
695699

696700
/// If a IDE inspection buffer has been set, returns the corresponding source

lib/Frontend/Frontend.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,23 @@ bool CompilerInstance::setup(const CompilerInvocation &Invoke,
562562
return false;
563563
}
564564

565+
bool CompilerInstance::setupForReplay(const CompilerInvocation &Invoke,
566+
std::string &Error,
567+
ArrayRef<const char *> Args) {
568+
// This is the fast path for setup an instance for replay but cannot run
569+
// regular compilation.
570+
Invocation = Invoke;
571+
572+
if (setupCASIfNeeded(Args)) {
573+
Error = "Setting up CAS failed";
574+
return true;
575+
}
576+
577+
setupOutputBackend();
578+
setupCachingDiagnosticsProcessorIfNeeded();
579+
return false;
580+
}
581+
565582
bool CompilerInstance::setUpVirtualFileSystemOverlays() {
566583
if (Invocation.getCASOptions().requireCASFS()) {
567584
const auto &Opts = getInvocation().getCASOptions();

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ static llvm::Error replayCompilation(SwiftScanReplayInstance &Instance,
932932
Invocation.getDiagnosticOptions().EmitMacroExpansionFiles);
933933

934934
std::string InstanceSetupError;
935-
if (Inst.setup(Instance.Invocation, InstanceSetupError, Instance.Args))
935+
if (Inst.setupForReplay(Instance.Invocation, InstanceSetupError,
936+
Instance.Args))
936937
return createStringError(inconvertibleErrorCode(), InstanceSetupError);
937938

938939
auto *CDP = Inst.getCachingDiagnosticsProcessor();

0 commit comments

Comments
 (0)