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

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 12:48:10 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

<details>
<summary>Changes</summary>

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%.

---
Full diff: https://github.com/llvm/llvm-project/pull/115065.diff


1 Files Affected:

- (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp (+3-1) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/115065


More information about the cfe-commits mailing list