<div dir="rtl"><div dir="ltr">Running ARCMT clang tests with these two tools stopped working for me after updating to trunk today, on WIndows 64 bit Visual C++ 2013 building 32 bit target. They just hang and never finish. I thought initially that's related to them running in thread but the same happens even if the thread is disabled in main() and cindextest_main() is called directly. </div>

<div dir="ltr">llvm tests complete OK as are other clang tests that do not use <span style="font-family:arial,sans-serif;font-size:12.727272033691406px">c-arcmt-test and and c-index-test.</span></div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br>

</span></div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">It this possibly related to mutex changes?</span></div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Maybe LLVM must be built with threads to support the ARCMT tests?</span></div>

<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></span></div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.727272033691406px">Yaron</span></div><div dir="ltr">

<span style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></span></div><div dir="ltr"><br></div></div><div class="gmail_extra"><div dir="ltr"><br><br><div class="gmail_quote">2014-06-20 19:40 GMT+03:00 Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span>:<br>

<blockquote class="gmail_quote" style="margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">It should continue to work.  The only thing llvm_start_multithreaded() and llvm_stop_multithreaded() did before, despite their names, was to allocate a mutex on the heap that served as a global lock.  In other words, it didn't really do much of anything useful.  You could still create threads even if you compiled with LLVM_ENABLE_THREADS=0.  Some stuff might not have been safe for concurrent access, but a) that's not an issue with these tests anyway, since they create the thread and then join, so there is no concurrency, and b) the areas that were conditionally protected by this global lock before are now always protected.<div>


<br></div><div>In fact, this makes me wonder if we even need the compile time flag.  </div></blockquote></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 20, 2014 at 9:34 AM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr">Two of the clang test tools, c-arcmt-test and and c-index-test always run the test through one thread only:</div>


<div dir="ltr"><br></div><div dir="ltr">

<div dir="ltr">/* We intentionally run in a separate thread to ensure we at least minimal</div><div dir="ltr"> * testing of a multithreaded environment (for example, having a reduced stack</div><div dir="ltr"> * size). */</div>




<div><br></div><div>If LLVM/clang were built without thread support, can these tools continue the same?</div><div><br></div><div>Yaron</div><div><br></div></div><div dir="ltr"><br></div></div><div class="gmail_extra"><br>




<br><div class="gmail_quote"><div dir="ltr">2014-06-19 21:18 GMT+03:00 Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span>:</div><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




Author: zturner<br>
Date: Thu Jun 19 13:18:23 2014<br>
New Revision: 211287<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=211287&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=211287&view=rev</a><br>
Log:<br>
Remove support for LLVM runtime multi-threading.<br>
<br>
After a number of previous small iterations, the functions<br>
llvm_start_multithreaded() and llvm_stop_multithreaded() have<br>
been reduced essentially to no-ops.  This change removes them<br>
entirely.<br>
<br>
Reviewed by: rnk, dblaikie<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D4216" target="_blank">http://reviews.llvm.org/D4216</a><br>
<br>
Modified:<br>
    llvm/trunk/docs/ProgrammersManual.rst<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/Threading.cpp<br>
    llvm/trunk/unittests/Support/ManagedStatic.cpp<br>
<br>
Modified: llvm/trunk/docs/ProgrammersManual.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/docs/ProgrammersManual.rst (original)<br>
+++ llvm/trunk/docs/ProgrammersManual.rst Thu Jun 19 13:18:23 2014<br>
@@ -2170,46 +2170,13 @@ compiler, consider compiling LLVM and LL<br>
 using the resultant compiler to build a copy of LLVM with multithreading<br>
 support.<br>
<br>
-.. _startmultithreaded:<br>
-<br>
-Entering and Exiting Multithreaded Mode<br>
----------------------------------------<br>
-<br>
-In order to properly protect its internal data structures while avoiding<br>
-excessive locking overhead in the single-threaded case, the LLVM must intialize<br>
-certain data structures necessary to provide guards around its internals.  To do<br>
-so, the client program must invoke ``llvm_start_multithreaded()`` before making<br>
-any concurrent LLVM API calls.  To subsequently tear down these structures, use<br>
-the ``llvm_stop_multithreaded()`` call.  You can also use the<br>
-``llvm_is_multithreaded()`` call to check the status of multithreaded mode.<br>
-<br>
-Note that both of these calls must be made *in isolation*.  That is to say that<br>
-no other LLVM API calls may be executing at any time during the execution of<br>
-``llvm_start_multithreaded()`` or ``llvm_stop_multithreaded``.  It is the<br>
-client's responsibility to enforce this isolation.<br>
-<br>
-The return value of ``llvm_start_multithreaded()`` indicates the success or<br>
-failure of the initialization.  Failure typically indicates that your copy of<br>
-LLVM was built without multithreading support, typically because GCC atomic<br>
-intrinsics were not found in your system compiler.  In this case, the LLVM API<br>
-will not be safe for concurrent calls.  However, it *will* be safe for hosting<br>
-threaded applications in the JIT, though :ref:`care must be taken<br>
-<jitthreading>` to ensure that side exits and the like do not accidentally<br>
-result in concurrent LLVM API calls.<br>
-<br>
 .. _shutdown:<br>
<br>
 Ending Execution with ``llvm_shutdown()``<br>
 -----------------------------------------<br>
<br>
 When you are done using the LLVM APIs, you should call ``llvm_shutdown()`` to<br>
-deallocate memory used for internal structures.  This will also invoke<br>
-``llvm_stop_multithreaded()`` if LLVM is operating in multithreaded mode.  As<br>
-such, ``llvm_shutdown()`` requires the same isolation guarantees as<br>
-``llvm_stop_multithreaded()``.<br>
-<br>
-Note that, if you use scope-based shutdown, you can use the<br>
-``llvm_shutdown_obj`` class, which calls ``llvm_shutdown()`` in its destructor.<br>
+deallocate memory used for internal structures.<br>
<br>
 .. _managedstatic:<br>
<br>
@@ -2217,15 +2184,11 @@ Lazy Initialization with ``ManagedStatic<br>
 ------------------------------------------<br>
<br>
 ``ManagedStatic`` is a utility class in LLVM used to implement static<br>
-initialization of static resources, such as the global type tables.  Before the<br>
-invocation of ``llvm_shutdown()``, it implements a simple lazy initialization<br>
-scheme.  Once ``llvm_start_multithreaded()`` returns, however, it uses<br>
+initialization of static resources, such as the global type tables.  In a<br>
+single-threaded environment, it implements a simple lazy initialization scheme.<br>
+When LLVM is compiled with support for multi-threading, however, it uses<br>
 double-checked locking to implement thread-safe lazy initialization.<br>
<br>
-Note that, because no other threads are allowed to issue LLVM API calls before<br>
-``llvm_start_multithreaded()`` returns, it is possible to have<br>
-``ManagedStatic``\ s of ``llvm::sys::Mutex``\ s.<br>
-<br>
 .. _llvmcontext:<br>
<br>
 Achieving Isolation with ``LLVMContext``<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=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/include/llvm-c/Core.h (original)<br>
+++ llvm/trunk/include/llvm-c/Core.h Thu Jun 19 13:18:23 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=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/include/llvm/Support/ManagedStatic.h (original)<br>
+++ llvm/trunk/include/llvm/Support/ManagedStatic.h Thu Jun 19 13:18:23 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=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/include/llvm/Support/Threading.h (original)<br>
+++ llvm/trunk/include/llvm/Support/Threading.h Thu Jun 19 13:18:23 2014<br>
@@ -7,30 +7,19 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
 //<br>
-// TThis file defines llvm_start_multithreaded() and friends.<br>
+// This file declares helper functions for running LLVM in a multi-threaded<br>
+// environment.<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
 #ifndef LLVM_SUPPORT_THREADING_H<br>
 #define LLVM_SUPPORT_THREADING_H<br>
<br>
-namespace llvm {<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>
+#include "llvm/Support/Mutex.h"<br>
<br>
-  /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe<br>
-  /// mode or not.<br>
+namespace llvm {<br>
+  /// Returns true if LLVM is compiled with support for multi-threading, and<br>
+  /// 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=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/lib/IR/Core.cpp (original)<br>
+++ llvm/trunk/lib/IR/Core.cpp Thu Jun 19 13:18:23 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/Threading.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/lib/Support/Threading.cpp (original)<br>
+++ llvm/trunk/lib/Support/Threading.cpp Thu Jun 19 13:18:23 2014<br>
@@ -7,7 +7,8 @@<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
 //<br>
-// This file implements llvm_start_multithreaded() and friends.<br>
+// This file defines helper functions for running LLVM in a multi-threaded<br>
+// environment.<br>
 //<br>
 //===----------------------------------------------------------------------===//<br>
<br>
@@ -19,38 +20,14 @@<br>
<br>
 using namespace llvm;<br>
<br>
-static bool multithreaded_mode = false;<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/unittests/Support/ManagedStatic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211287&r1=211286&r2=211287&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211287&r1=211286&r2=211287&view=diff</a><br>





==============================================================================<br>
--- llvm/trunk/unittests/Support/ManagedStatic.cpp (original)<br>
+++ llvm/trunk/unittests/Support/ManagedStatic.cpp Thu Jun 19 13:18:23 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" target="_blank">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></div></div><br></div>
</blockquote></div><br></div>
</div></div></div></div>