[clang] 57c7750 - [clang][DependencyScanner] Cache modulemap stat failures

Michael Spencer via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 7 15:14:25 PST 2023


Author: Michael Spencer
Date: 2023-03-07T15:13:55-08:00
New Revision: 57c7750f703ddee9025f819cdd01c9e97666e7ab

URL: https://github.com/llvm/llvm-project/commit/57c7750f703ddee9025f819cdd01c9e97666e7ab
DIFF: https://github.com/llvm/llvm-project/commit/57c7750f703ddee9025f819cdd01c9e97666e7ab.diff

LOG: [clang][DependencyScanner] Cache modulemap stat failures

Add `module.modulemap` as a file we cache stat failures for as there
are a lot of stats for this file.

Clang currently uses the files it should minimize as a proxy for files
it should cache stat failures for, but really we should cache stat
failures for all paths we don't expect to change during the build.
Unfortunately the VFS API does not know _why_ clang is trying to stat
a path, so we use the filename as a proxy.

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

Added: 
    

Modified: 
    clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 97b41fc689176..0ddb5c24c5e6c 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -181,7 +181,11 @@ static bool shouldCacheStatFailures(StringRef Filename) {
   StringRef Ext = llvm::sys::path::extension(Filename);
   if (Ext.empty())
     return false; // This may be the module cache directory.
-  // Only cache stat failures on source files.
+  // Only cache stat failures on files that are not expected to change during
+  // the build.
+  StringRef FName = llvm::sys::path::filename(Filename);
+  if (FName == "module.modulemap" || FName == "module.map")
+    return true;
   return shouldScanForDirectivesBasedOnExtension(Filename);
 }
 


        


More information about the cfe-commits mailing list