aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Signposts.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2021-01-19 11:37:45 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2021-01-19 11:41:54 -0800
commita4b42c621b9e2009cfd8bc9265bbf970c7231271 (patch)
tree4396863cd684278c2d2609b16e9a15b94165d6df /llvm/lib/Support/Signposts.cpp
parent6ac9cb2a7c6c19797fc778f3d441a6fb7b69793c (diff)
downloadllvm-a4b42c621b9e2009cfd8bc9265bbf970c7231271.zip
llvm-a4b42c621b9e2009cfd8bc9265bbf970c7231271.tar.gz
llvm-a4b42c621b9e2009cfd8bc9265bbf970c7231271.tar.bz2
[llvm] Protect signpost map with a mutex
Use a mutex to protect concurrent access to the signpost map. This fixes nondeterministic crashes in LLDB that appeared after using signposts in the timer implementation. Differential revision: https://reviews.llvm.org/D94285
Diffstat (limited to 'llvm/lib/Support/Signposts.cpp')
-rw-r--r--llvm/lib/Support/Signposts.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Support/Signposts.cpp b/llvm/lib/Support/Signposts.cpp
index 91ce909..9353e9b 100644
--- a/llvm/lib/Support/Signposts.cpp
+++ b/llvm/lib/Support/Signposts.cpp
@@ -13,6 +13,7 @@
#include "llvm/Config/config.h"
#if LLVM_SUPPORT_XCODE_SIGNPOSTS
#include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/Mutex.h"
#include <os/signpost.h>
#endif // if LLVM_SUPPORT_XCODE_SIGNPOSTS
@@ -38,9 +39,11 @@ class SignpostEmitterImpl {
LogPtrTy SignpostLog;
DenseMap<const void *, os_signpost_id_t> Signposts;
+ sys::SmartMutex<true> Mutex;
LogTy &getLogger() const { return *SignpostLog; }
os_signpost_id_t getSignpostForObject(const void *O) {
+ sys::SmartScopedLock<true> Lock(Mutex);
const auto &I = Signposts.find(O);
if (I != Signposts.end())
return I->second;