diff options
author | Zachary Turner <zturner@google.com> | 2014-06-10 23:01:20 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-06-10 23:01:20 +0000 |
commit | f6054ca18c86eaa4c204672404a4b9d24cb5233c (patch) | |
tree | 402ec755c91d48d7023e6d14c7cd4f660835355d /llvm/lib/Support/ManagedStatic.cpp | |
parent | f63bc64df55c4a35e6b0edeae1396225be6a7ce9 (diff) | |
download | bcm5719-llvm-f6054ca18c86eaa4c204672404a4b9d24cb5233c.tar.gz bcm5719-llvm-f6054ca18c86eaa4c204672404a4b9d24cb5233c.zip |
Remove support for runtime multi-threading.
This patch removes the functions llvm_start_multithreaded() and
llvm_stop_multithreaded(), and changes llvm_is_multithreaded()
to return a constant value based on the value of the compile-time
definition LLVM_ENABLE_THREADS.
Previously, it was possible to have compile-time support for
threads on, and runtime support for threads off, in which case
certain mutexes were not allocated or ever acquired. Now, if the
build is created with threads enabled, mutexes are always acquired.
A test before/after patch of compiling a very large TU showed no
noticeable performance impact of this change.
Reviewers: rnk
Differential Revision: http://reviews.llvm.org/D4076
llvm-svn: 210600
Diffstat (limited to 'llvm/lib/Support/ManagedStatic.cpp')
-rw-r--r-- | llvm/lib/Support/ManagedStatic.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp index 6a1c2a545a8..74884d93304 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -15,6 +15,7 @@ #include "llvm/Config/config.h" #include "llvm/Support/Atomic.h" #include <cassert> +#include <mutex> using namespace llvm; static const ManagedStaticBase *StaticList = nullptr; @@ -23,7 +24,7 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { assert(Creator); if (llvm_is_multithreaded()) { - llvm_acquire_global_lock(); + std::lock_guard<llvm::recursive_mutex> Lock(llvm_get_global_lock()); if (!Ptr) { void* tmp = Creator(); @@ -44,7 +45,6 @@ void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), StaticList = this; } - llvm_release_global_lock(); } else { assert(!Ptr && !DeleterFn && !Next && "Partially initialized ManagedStatic!?"); @@ -77,6 +77,4 @@ void ManagedStaticBase::destroy() const { void llvm::llvm_shutdown() { while (StaticList) StaticList->destroy(); - - if (llvm_is_multithreaded()) llvm_stop_multithreaded(); } |