Commit Graph

15 Commits

Author SHA1 Message Date
Steven Wu
1d402d2d62 [CachedDiagnostics] Optimize in case no diagnostics is emitted
When no diagnostics is emitted from the compilation, just use an empty
object as cached diagnostics. That is an optimization for storage to
avoid emitting some supporting file to recreate source manager when not
needed, also save a bit time from emitting YAML file.

rdar://128426132
2024-10-09 09:17:01 -07:00
Steven Wu
30737eb396 [Caching] Support swift style diagnostics for swift caching
Add support for swift style diagnostics for swift caching. This includes
pre-populate the GeneratedSourceInfo with macro name so it doesn't need
to infer from an ASTNode, which the caching mechanism cannot preserve.

Still leave the default diagnostic style to LLVM style because replaying
swift style diagnostics is still very slow and including parsing source
file using swift-syntax.

rdar://128615572
2024-07-08 16:15:44 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Steven Wu
c132f74c3c [Caching] Don't rely on FileSystem when replaying diagnostics
Stop relying on file system to provide source buffer for diagnostics
when replying. This avoids initializing CASFS which is quite expensive.
Now cached diagnostics contains CASID for the file buffer so it can
initialize its own source manager without relying on the underlying file
system.

rdar://128423393
2024-05-31 14:51:26 -07:00
Steven Wu
4e246dfdfd [Caching] Fix stack-use-after-scope in CachedDiagnostics
Fix a stack-use-after-scope in the CachedDiagnostics when the
DiagnosticInfo entry that is getting deserialized has ChildDiagnostics.

There are some fields in the DiagnosticInfo are not owned by the
DiagnosticsInfo itself. While the callback during the deserialization
ensures those fields are still alive for the top level DiagnosticInfo
when it gets used, it is not true for any child diagnostics info inside.

rdar://123846525
2024-03-08 11:01:15 -08:00
Steven Wu
3986937e03 [Caching][NFC] Restructure CASOption in swift. NFC
Clean up how CASOptions are kept and passed inside swift to make the
code more readable. Also avoid a copy of CAS configuration in
ClangImporter.
2024-02-11 14:08:09 -08:00
Steven Wu
76bde39ee7 [Caching] Encoding cache key for input file with index instead of path
Avoid path encoding difference (for example, real_path vs. path from
symlink) by eliminating the path from cache key. Cache key is now
encoded with the index of the input file from all the input files from
the command-line, reguardless if those inputs will produce output or
not. This is to ensure stable ordering even the batching is different.

Add a new cache computation API that is preferred for using input index
directly. Old API for cache key is deprecated but still updated to
fallback to real_path comparsion if needed.

As a result of swift scan API change, rename the feature in JSON file to
avoid version confusion between swift-driver and libSwiftScan.

rdar://119387650
2023-12-18 14:06:00 -08:00
Steven Wu
30cfa3deb2 [Caching] Re-associate diagnostics cache key with InputFile
Change how cached diagnostics are stored inside the CAS. It used to be
stored as a standalone entry for a frontend invocation in the cache and
now it is switched to be associated with input files, stored together
with other outputs like object files, etc.

This enables cleaner Cache Replay APIs and future cached diagnostics
that can be splitted up by file contribution.
2023-10-30 16:02:19 -07:00
Steven Wu
6c3097657a [Caching] Change swift cache key computation
Update swift cache key computation mechanism from one cache key per
output, to one cache key per primary input file (for all outputs that
associated with that input).

The new schema allows fewer cache lookups while still preserving most of
the flexibility for batch mode and incremental mode.
2023-10-13 09:15:22 -07:00
Steven Wu
c8bc08107c Merge pull request #68684 from cachemeifyoucan/eng/PR-path-remapping
[CompilerCaching] Path Remapping for canonicalization
2023-10-04 12:57:27 -07:00
Tony Allevato
5f5b24f96e [C++20] Make operator{==,!=}s const.
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
Steven Wu
5be305e839 [CompilerCaching] Teach CachedDiagnostics to replay with prefix map
Teach CachedDiagnosticsProcessor to replay diagnostics for all consumers
with a different path using a path prefix map. This allows diagnostics
to be replayed for the actual path on disk after the scanner
canonicalized the path for compilation.
2023-09-26 12:36:43 -07:00
Steven Wu
b78b569450 [CAS] Consolidate compile cache flags
Rename `-enable-cas` to `-compile-cache-job` to align with clang option
names and promote that to a new driver only flag.

Few other additions to driver flag for caching behaviors:
* `-compile-cache-remarks`: now cache hit/miss remarks are guarded behind
  this flag
* `-compile-cache-skip`: skip replaying from the cache. Useful as a
  debugging tool to do the compilation using CAS inputs even the output
  is a hit from the cache.
2023-06-26 10:34:27 -07:00
Steven Wu
1b70ba1ce2 Fix CachingDiagnosticsProcessor when replay by FileSpecificDiagConsumer
When using a FileSpecificDiagConsumer, the source file that doesn't have
any diagnostics need to exist in the source manager for the consumer to
be successfully created.
2023-06-12 13:22:10 -07:00
Steven Wu
d3891a86ba [CAS] Add caching diagnostic processor
Add a CachedDiagnosticsProcessor that is a DiagConsumer can capture all
the diagnostics during a compilation, serialized them into CAS with a
format that can be replayed without re-compiling.
2023-04-27 13:36:49 -07:00