Skip to content

Tweak caching remarks and options #67376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ def cache_compile_job: Flag<["-"], "cache-compile-job">,
Flags<[FrontendOption, NewDriverOnlyOption]>,
HelpText<"Enable compiler caching">;

def cache_remarks: Flag<["-"], "cache-remarks">,
def cache_remarks: Flag<["-"], "Rcache-compile-job">,
Flags<[FrontendOption, NewDriverOnlyOption]>,
HelpText<"Show remarks for compiler caching">;

Expand Down
4 changes: 4 additions & 0 deletions lib/Frontend/CachingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ bool replayCachedCompilerOutputs(
Diag.diagnose(SourceLoc(), diag::error_replay_cached_diag,
toString(std::move(E)));
return false;
} else {
if (CacheRemarks)
Diag.diagnose(SourceLoc(), diag::replay_output, "<cached-diagnostics>",
DiagnosticsOutput->Key);
}

// Replay the result only when everything is resolved.
Expand Down
12 changes: 7 additions & 5 deletions test/CAS/cache_replay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

/// Run the command first time, expect cache miss.
/// FIXME: This command doesn't use `-cas-fs` so it is not a good cache entry. It is currently allowed so it is easier to write tests.
// RUN: %target-swift-frontend -cache-compile-job -cache-remarks %s -emit-module -emit-module-path %t/Test.swiftmodule -c -emit-dependencies \
// RUN: %target-swift-frontend -cache-compile-job -Rcache-compile-job %s -emit-module -emit-module-path %t/Test.swiftmodule -c -emit-dependencies \
// RUN: -module-name Test -o %t/test.o -cas-path %t/cas -allow-unstable-cache-key-for-testing 2>&1 | %FileCheck --check-prefix=CACHE-MISS %s

/// Expect cache hit for second time.
// RUN: %target-swift-frontend -cache-compile-job -cache-remarks %s -emit-module -emit-module-path %t/Test.swiftmodule -c -emit-dependencies \
// RUN: %target-swift-frontend -cache-compile-job -Rcache-compile-job %s -emit-module -emit-module-path %t/Test.swiftmodule -c -emit-dependencies \
// RUN: -module-name Test -o %t/test.o -cas-path %t/cas -allow-unstable-cache-key-for-testing 2>&1 | %FileCheck --check-prefix=CACHE-HIT %s

/// Expect cache hit a subset of outputs.
// RUN: %target-swift-frontend -cache-compile-job -cache-remarks %s -emit-module -emit-module-path %t/Test.swiftmodule -c \
// RUN: %target-swift-frontend -cache-compile-job -Rcache-compile-job %s -emit-module -emit-module-path %t/Test.swiftmodule -c \
// RUN: -module-name Test -o %t/test.o -cas-path %t/cas -allow-unstable-cache-key-for-testing 2>&1 | %FileCheck --check-prefix=CACHE-HIT %s

/// Skip cache
// RUN: %target-swift-frontend -cache-compile-job -cache-remarks -cache-disable-replay %s -emit-module -emit-module-path %t/Test.swiftmodule -c \
// RUN: %target-swift-frontend -cache-compile-job -Rcache-compile-job -cache-disable-replay %s -emit-module -emit-module-path %t/Test.swiftmodule -c \
// RUN: -module-name Test -o %t/test.o -cas-path %t/cas -allow-unstable-cache-key-for-testing 2>&1 | %FileCheck --allow-empty --check-prefix=SKIP-CACHE %s

// CACHE-MISS: remark: cache miss output file
// CACHE-HIT: remark: replay output file
// CACHE-HIT: remark: replay output file '<cached-diagnostics>': key 'llvmcas://{{.*}}'
// CACHE-HIT: remark: replay output file '{{.*}}{{/|\\}}test.o': key 'llvmcas://{{.*}}'
// CACHE-HIT: remark: replay output file '{{.*}}{{/|\\}}Test.swiftmodule': key 'llvmcas://{{.*}}'
// SKIP-CACHE-NOT: remark:

func testFunc() {}