-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Enable making the CompilerInstance
module dependency collector thread-safe
#137227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jansvoboda11
merged 1 commit into
llvm:main
from
jansvoboda11:instance-thread-safe-mod-dep-collector
Apr 29, 2025
Merged
[clang] Enable making the CompilerInstance
module dependency collector thread-safe
#137227
jansvoboda11
merged 1 commit into
llvm:main
from
jansvoboda11:instance-thread-safe-mod-dep-collector
Apr 29, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…tor thread-safe The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
@llvm/pr-subscribers-clang Author: Jan Svoboda (jansvoboda11) ChangesThe same principle as #135473, #135737, #136178, #136601 & #137059. Full diff: https://github.com/llvm/llvm-project/pull/137227.diff 2 Files Affected:
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index 8c91a2a86cfcd..b5b4de03e45f1 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -839,16 +839,23 @@ class CompilerInstance : public ModuleLoader {
class ThreadSafeCloneConfig {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;
DiagnosticConsumer &DiagConsumer;
+ std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector;
public:
- ThreadSafeCloneConfig(IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
- DiagnosticConsumer &DiagConsumer)
- : VFS(std::move(VFS)), DiagConsumer(DiagConsumer) {
+ ThreadSafeCloneConfig(
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
+ DiagnosticConsumer &DiagConsumer,
+ std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector = nullptr)
+ : VFS(std::move(VFS)), DiagConsumer(DiagConsumer),
+ ModuleDepCollector(std::move(ModuleDepCollector)) {
assert(this->VFS && "Clone config requires non-null VFS");
}
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getVFS() const { return VFS; }
DiagnosticConsumer &getDiagConsumer() const { return DiagConsumer; }
+ std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const {
+ return ModuleDepCollector;
+ }
};
private:
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 1526ea53add7d..58a01459f3c64 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1257,10 +1257,14 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
Instance.GetDependencyDirectives =
GetDependencyDirectives->cloneFor(Instance.getFileManager());
- // If we're collecting module dependencies, we need to share a collector
- // between all of the module CompilerInstances. Other than that, we don't
- // want to produce any dependency output from the module build.
- Instance.setModuleDepCollector(getModuleDepCollector());
+ if (ThreadSafeConfig) {
+ Instance.setModuleDepCollector(ThreadSafeConfig->getModuleDepCollector());
+ } else {
+ // If we're collecting module dependencies, we need to share a collector
+ // between all of the module CompilerInstances. Other than that, we don't
+ // want to produce any dependency output from the module build.
+ Instance.setModuleDepCollector(getModuleDepCollector());
+ }
Inv.getDependencyOutputOpts() = DependencyOutputOptions();
return InstancePtr;
|
vsapsai
approved these changes
Apr 29, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…tor thread-safe (llvm#137227) The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…tor thread-safe (llvm#137227) The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…tor thread-safe (llvm#137227) The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
…tor thread-safe (llvm#137227) The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
…tor thread-safe (llvm#137227) The same principle as llvm#135473, llvm#135737, llvm#136178, llvm#136601 & llvm#137059.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The same principle as #135473, #135737, #136178, #136601 & #137059.