[PATCH] D94285: [llvm] Protect signpost map with a mutex

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 08:41:29 PST 2021


JDevlieghere updated this revision to Diff 317589.
JDevlieghere added a comment.

Use `SmartMutex` and `SmartScopedLock`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94285/new/

https://reviews.llvm.org/D94285

Files:
  llvm/lib/Support/Signposts.cpp


Index: llvm/lib/Support/Signposts.cpp
===================================================================
--- llvm/lib/Support/Signposts.cpp
+++ 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 @@
 
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94285.317589.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210119/a3324afc/attachment.bin>


More information about the llvm-commits mailing list