<div dir="ltr">This change was reverted in r211072 due to accidentally pushing a whole branch instead of a single CL.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 16, 2014 at 3:40 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: zturner<br>
Date: Mon Jun 16 17:40:17 2014<br>
New Revision: 211067<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=211067&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=211067&view=rev</a><br>
Log:<br>
Remove some more code out into a separate CL.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm-c/Core.h<br>
    llvm/trunk/include/llvm/Support/ManagedStatic.h<br>
    llvm/trunk/include/llvm/Support/Threading.h<br>
    llvm/trunk/lib/IR/Core.cpp<br>
    llvm/trunk/lib/Support/ManagedStatic.cpp<br>
    llvm/trunk/lib/Support/Threading.cpp<br>
    llvm/trunk/lib/Support/Timer.cpp<br>
    llvm/trunk/unittests/Support/ManagedStatic.cpp<br>
<br>
Modified: llvm/trunk/include/llvm-c/Core.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm-c/Core.h (original)<br>
+++ llvm/trunk/include/llvm-c/Core.h Mon Jun 16 17:40:17 2014<br>
@@ -2848,16 +2848,13 @@ void LLVMDisposePassManager(LLVMPassMana<br>
  * @{<br>
  */<br>
<br>
-/** Allocate and initialize structures needed to make LLVM safe for<br>
-    multithreading. The return value indicates whether multithreaded<br>
-    initialization succeeded. Must be executed in isolation from all<br>
-    other LLVM api calls.<br>
-    @see llvm::llvm_start_multithreaded */<br>
+/** Deprecated: Multi-threading can only be enabled/disabled with the compile<br>
+    time define LLVM_ENABLE_THREADS.  This function always returns<br>
+    LLVMIsMultithreaded(). */<br>
 LLVMBool LLVMStartMultithreaded(void);<br>
<br>
-/** Deallocate structures necessary to make LLVM safe for multithreading.<br>
-    Must be executed in isolation from all other LLVM api calls.<br>
-    @see llvm::llvm_stop_multithreaded */<br>
+/** Deprecated: Multi-threading can only be enabled/disabled with the compile<br>
+    time define LLVM_ENABLE_THREADS. */<br>
 void LLVMStopMultithreaded(void);<br>
<br>
 /** Check whether LLVM is executing in thread-safe mode or not.<br>
<br>
Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/Support/ManagedStatic.h (original)<br>
+++ llvm/trunk/include/llvm/Support/ManagedStatic.h Mon Jun 16 17:40:17 2014<br>
@@ -103,9 +103,6 @@ void llvm_shutdown();<br>
 /// llvm_shutdown() when it is destroyed.<br>
 struct llvm_shutdown_obj {<br>
   llvm_shutdown_obj() { }<br>
-  explicit llvm_shutdown_obj(bool multithreaded) {<br>
-    if (multithreaded) llvm_start_multithreaded();<br>
-  }<br>
   ~llvm_shutdown_obj() { llvm_shutdown(); }<br>
 };<br>
<br>
<br>
Modified: llvm/trunk/include/llvm/Support/Threading.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/Support/Threading.h (original)<br>
+++ llvm/trunk/include/llvm/Support/Threading.h Mon Jun 16 17:40:17 2014<br>
@@ -7,7 +7,8 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
 //<br>
-// TThis file defines llvm_start_multithreaded() and friends.<br>
+// This file defines helper functions for running LLVM in a multi-threaded<br>
+// environment.<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
@@ -17,25 +18,12 @@<br>
 #include "llvm/Support/Mutex.h"<br>
<br>
 namespace llvm {<br>
-  /// llvm_get_global_lock - returns the llvm global lock object.<br>
-  sys::Mutex& llvm_get_global_lock();<br>
<br>
-  /// llvm_start_multithreaded - Allocate and initialize structures needed to<br>
-  /// make LLVM safe for multithreading.  The return value indicates whether<br>
-  /// multithreaded initialization succeeded.  LLVM will still be operational<br>
-  /// on "failed" return, and will still be safe for hosting threading<br>
-  /// applications in the JIT, but will not be safe for concurrent calls to the<br>
-  /// LLVM APIs.<br>
-  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.<br>
-  bool llvm_start_multithreaded();<br>
-<br>
-  /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM<br>
-  /// safe for multithreading.<br>
-  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.<br>
-  void llvm_stop_multithreaded();<br>
+  /// llvm_get_global_lock() - returns the llvm global lock object.<br>
+  sys::Mutex &llvm_get_global_lock();<br>
<br>
-  /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe<br>
-  /// mode or not.<br>
+  /// llvm_is_multithreaded() - returns true if LLVM is compiled with support<br>
+  /// for multiple threads, and false otherwise.<br>
   bool llvm_is_multithreaded();<br>
<br>
   /// llvm_execute_on_thread - Execute the given \p UserFn on a separate<br>
<br>
Modified: llvm/trunk/lib/IR/Core.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/IR/Core.cpp (original)<br>
+++ llvm/trunk/lib/IR/Core.cpp Mon Jun 16 17:40:17 2014<br>
@@ -2702,11 +2702,10 @@ void LLVMDisposePassManager(LLVMPassMana<br>
 /*===-- Threading ------------------------------------------------------===*/<br>
<br>
 LLVMBool LLVMStartMultithreaded() {<br>
-  return llvm_start_multithreaded();<br>
+  return LLVMIsMultithreaded();<br>
 }<br>
<br>
 void LLVMStopMultithreaded() {<br>
-  llvm_stop_multithreaded();<br>
 }<br>
<br>
 LLVMBool LLVMIsMultithreaded() {<br>
<br>
Modified: llvm/trunk/lib/Support/ManagedStatic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/ManagedStatic.cpp (original)<br>
+++ llvm/trunk/lib/Support/ManagedStatic.cpp Mon Jun 16 17:40:17 2014<br>
@@ -24,7 +24,7 @@ void ManagedStaticBase::RegisterManagedS<br>
                                               void (*Deleter)(void*)) const {<br>
   assert(Creator);<br>
   if (llvm_is_multithreaded()) {<br>
-    llvm::MutexGuard Lock(llvm::llvm_get_global_lock());<br>
+    llvm::MutexGuard Lock(llvm_get_global_lock());<br>
<br>
     if (!Ptr) {<br>
       void* tmp = Creator();<br>
@@ -76,6 +76,4 @@ void ManagedStaticBase::destroy() const<br>
 void llvm::llvm_shutdown() {<br>
   while (StaticList)<br>
     StaticList->destroy();<br>
-<br>
-  if (llvm_is_multithreaded()) llvm_stop_multithreaded();<br>
 }<br>
<br>
Modified: llvm/trunk/lib/Support/Threading.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/Threading.cpp (original)<br>
+++ llvm/trunk/lib/Support/Threading.cpp Mon Jun 16 17:40:17 2014<br>
@@ -7,7 +7,8 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
 //<br>
-// This file implements llvm_start_multithreaded() and friends.<br>
+// This file implements helper functions for running LLVM in a multi-threaded<br>
+// environment.<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
@@ -19,43 +20,19 @@<br>
<br>
 using namespace llvm;<br>
<br>
-static bool multithreaded_mode = false;<br>
-<br>
 sys::Mutex& llvm::llvm_get_global_lock() {<br>
   static sys::Mutex global_lock;<br>
   return global_lock;<br>
 }<br>
<br>
-bool llvm::llvm_start_multithreaded() {<br>
+bool llvm::llvm_is_multithreaded() {<br>
 #if LLVM_ENABLE_THREADS != 0<br>
-  assert(!multithreaded_mode && "Already multithreaded!");<br>
-  multithreaded_mode = true;<br>
-<br>
-  // We fence here to ensure that all initialization is complete BEFORE we<br>
-  // return from llvm_start_multithreaded().<br>
-  sys::MemoryFence();<br>
   return true;<br>
 #else<br>
   return false;<br>
 #endif<br>
 }<br>
<br>
-void llvm::llvm_stop_multithreaded() {<br>
-#if LLVM_ENABLE_THREADS != 0<br>
-  assert(multithreaded_mode && "Not currently multithreaded!");<br>
-<br>
-  // We fence here to insure that all threaded operations are complete BEFORE we<br>
-  // return from llvm_stop_multithreaded().<br>
-  sys::MemoryFence();<br>
-<br>
-  multithreaded_mode = false;<br>
-#endif<br>
-}<br>
-<br>
-bool llvm::llvm_is_multithreaded() {<br>
-  return multithreaded_mode;<br>
-}<br>
-<br>
 #if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)<br>
 #include <pthread.h><br>
<br>
<br>
Modified: llvm/trunk/lib/Support/Timer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/Timer.cpp (original)<br>
+++ llvm/trunk/lib/Support/Timer.cpp Mon Jun 16 17:40:17 2014<br>
@@ -18,7 +18,7 @@<br>
 #include "llvm/Support/FileSystem.h"<br>
 #include "llvm/Support/Format.h"<br>
 #include "llvm/Support/ManagedStatic.h"<br>
-#include "llvm/support/MutexGuard.h"<br>
+#include "llvm/Support/MutexGuard.h"<br>
 #include "llvm/Support/Process.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
 using namespace llvm;<br>
<br>
Modified: llvm/trunk/unittests/Support/ManagedStatic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211067&r1=211066&r2=211067&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211067&r1=211066&r2=211067&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/unittests/Support/ManagedStatic.cpp (original)<br>
+++ llvm/trunk/unittests/Support/ManagedStatic.cpp Mon Jun 16 17:40:17 2014<br>
@@ -47,7 +47,6 @@ TEST(Initialize, MultipleThreads) {<br>
   void *p1 = test1::allocate_stack(a1);<br>
   void *p2 = test1::allocate_stack(a2);<br>
<br>
-  llvm_start_multithreaded();<br>
   pthread_t t1, t2;<br>
   pthread_create(&t1, &a1, test1::helper, nullptr);<br>
   pthread_create(&t2, &a2, test1::helper, nullptr);<br>
@@ -55,7 +54,6 @@ TEST(Initialize, MultipleThreads) {<br>
   pthread_join(t2, nullptr);<br>
   free(p1);<br>
   free(p2);<br>
-  llvm_stop_multithreaded();<br>
 }<br>
 #endif<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>