[clang][deps] Do not cache PCM files
authorJan Svoboda <jan_svoboda@apple.com>
Mon, 15 May 2023 21:26:10 +0000 (14:26 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Tue, 16 May 2023 00:43:54 +0000 (17:43 -0700)
On incremental scan, caching an out-of-date PCM on the VFS layer causes each TU and each module to recompile the PCM again. This is huge performance problem. Stop caching ".pcm" files.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D150615

clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

index 0ddb5c2..3140485 100644 (file)
@@ -262,6 +262,9 @@ DependencyScanningWorkerFilesystem::status(const Twine &Path) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+    return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr<EntryRef> Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
     return Result.getError();
@@ -319,6 +322,9 @@ DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+    return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr<EntryRef> Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
     return Result.getError();