[PATCH] Replace all standard mutexes with equivalent stl mutexes.

Chandler Carruth chandlerc at gmail.com
Thu Jun 19 15:02:33 PDT 2014


Any particular reason for universally using recursive_mutex? I feel like a lot of these would be pretty easily switched to mutex.

================
Comment at: lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp:34-35
@@ -34,4 +33,4 @@
 
 // Global mutex to ensure a single thread initializes oprofile agent.
-llvm::sys::Mutex OProfileInitializationMutex;
+std::recursive_mutex OProfileInitializationMutex;
 
----------------
This is entertainingly unlikely to be correct (both before and after your change)

================
Comment at: lib/Support/ErrorHandling.cpp:43
@@ -43,3 +42,3 @@
 
-static sys::Mutex ErrorHandlerMutex;
+static std::recursive_mutex ErrorHandlerMutex;
 
----------------
And another likely place we need a managed static.

================
Comment at: lib/Support/Unix/Process.inc:268
@@ -268,3 +267,3 @@
   // First, acquire a global lock because these C routines are thread hostile.
-  static sys::Mutex M;
-  MutexGuard G(M);
+  static std::recursive_mutex M;
+  std::lock_guard<std::recursive_mutex> G(M);
----------------
This looks like a bug on Windows, might be worth moving to a managed static.

================
Comment at: lib/Target/NVPTX/NVPTXUtilities.cpp:37
@@ -35,3 +36,3 @@
 ManagedStatic<per_module_annot_t> annotationCache;
-static sys::Mutex Lock;
+static std::recursive_mutex Lock;
 
----------------
And here.

http://reviews.llvm.org/D4223






More information about the llvm-commits mailing list