[clang] a6637ae - [clang][deps] Share `FileManager` between modules (#115065)

via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 14:21:04 PST 2024


Author: Jan Svoboda
Date: 2024-11-06T14:21:01-08:00
New Revision: a6637ae2cc9a0e7c9a37603b3d277d7ca642bc36

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

LOG: [clang][deps] Share `FileManager` between modules (#115065)

The `FileManager` sharing between module-building `CompilerInstance`s
was disabled a while ago due to `FileEntry::getName()` being unreliable.
Now that we use `FileEntryRef::getNameAsRequested()` in places where it
matters, re-enabling `FileManager` is sound and improves performance of
`clang-scan-deps` by ~6.2%.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index d77187bfb1f2b8..1deffe68003804 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -335,7 +335,9 @@ class DependencyScanningAction : public tooling::ToolAction {
 
     ScanInstance.getFrontendOpts().GenerateGlobalModuleIndex = false;
     ScanInstance.getFrontendOpts().UseGlobalModuleIndex = false;
-    ScanInstance.getFrontendOpts().ModulesShareFileManager = false;
+    // This will prevent us compiling individual modules asynchronously since
+    // FileManager is not thread-safe, but it does improve performance for now.
+    ScanInstance.getFrontendOpts().ModulesShareFileManager = true;
     ScanInstance.getHeaderSearchOpts().ModuleFormat = "raw";
     ScanInstance.getHeaderSearchOpts().ModulesIncludeVFSUsage =
         any(OptimizeArgs & ScanningOptimizations::VFS);


        


More information about the cfe-commits mailing list