[llvm] 89e775a - Switch from the std::shared_mutex to an LLVM RWMutex (#74383)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 18:06:22 PST 2023


Author: Kevin Frei
Date: 2023-12-04T21:06:18-05:00
New Revision: 89e775ac81ec9e5b45c3bdf39dc8e456c1f13690

URL: https://github.com/llvm/llvm-project/commit/89e775ac81ec9e5b45c3bdf39dc8e456c1f13690
DIFF: https://github.com/llvm/llvm-project/commit/89e775ac81ec9e5b45c3bdf39dc8e456c1f13690.diff

LOG: Switch from the std::shared_mutex to an LLVM RWMutex (#74383)

@nico pointed out that my usage of `std::shared_mutex` broke builds on
older macOS devices. Switching to `llvm::sys::RWMutex` is the solution
that they provided.

Tracked in issue #74382

Co-authored-by: Kevin Frei <freik at meta.com>

Added: 
    

Modified: 
    llvm/lib/Debuginfod/Debuginfod.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index c1cab8d79cabd..9df30ab55cbad 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -51,7 +51,7 @@ using llvm::object::BuildIDRef;
 namespace {
 std::optional<SmallVector<StringRef>> DebuginfodUrls;
 // Many Readers/Single Writer lock protecting the global debuginfod URL list.
-std::shared_mutex UrlsMutex;
+llvm::sys::RWMutex UrlsMutex;
 } // namespace
 
 static std::string uniqueKey(llvm::StringRef S) {
@@ -69,12 +69,12 @@ bool canUseDebuginfod() {
 }
 
 SmallVector<StringRef> getDefaultDebuginfodUrls() {
-  std::shared_lock<std::shared_mutex> ReadGuard(UrlsMutex);
+  std::shared_lock<llvm::sys::RWMutex> ReadGuard(UrlsMutex);
   if (!DebuginfodUrls) {
     // Only read from the environment variable if the user hasn't already
     // set the value
     ReadGuard.unlock();
-    std::unique_lock<std::shared_mutex> WriteGuard(UrlsMutex);
+    std::unique_lock<llvm::sys::RWMutex> WriteGuard(UrlsMutex);
     DebuginfodUrls = SmallVector<StringRef>();
     if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) {
       StringRef(DebuginfodUrlsEnv)
@@ -88,7 +88,7 @@ SmallVector<StringRef> getDefaultDebuginfodUrls() {
 
 // Set the default debuginfod URL list, override the environment variable
 void setDefaultDebuginfodUrls(const SmallVector<StringRef> &URLs) {
-  std::unique_lock<std::shared_mutex> WriteGuard(UrlsMutex);
+  std::unique_lock<llvm::sys::RWMutex> WriteGuard(UrlsMutex);
   DebuginfodUrls = URLs;
 }
 


        


More information about the llvm-commits mailing list