<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">We just observed that this caused widespread regressions in compile time. If you can tell us which commits fix those egregious cases (assuming there are not too many of them), we can take a closer look to see to what extent the regressions are fixed. We just missed the fact that you’d already made improvements here.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 18, 2014, at 2:17 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" class="">chandlerc@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I tried to solve it and failed. =[ It is deeply, fundamentally intertwined with the existing pass manager.<div class=""><br class=""></div><div class="">We solved some of the most egregious cases. The current problems I'm aware of only impact the cost of creating and tearing down a pass manager, or running passes with asserts enabled. I only see this show up as a real problem when running the regression test suite...</div><div class=""><br class=""></div><div class="">Do you have some specific use case that is continuing to cause you problems.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 18, 2014 at 1:12 PM, Bruno Cardoso Lopes <span dir="ltr" class=""><<a href="mailto:bruno.cardoso@gmail.com" target="_blank" class="">bruno.cardoso@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Ping :-)</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Sep 30, 2014 at 8:13 PM, Bruno Cardoso Lopes <span dir="ltr" class=""><<a href="mailto:bruno.cardoso@gmail.com" target="_blank" class="">bruno.cardoso@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Chandler,<br class="">
<br class="">
IIRC, you're working on a fix for the compile time regression caused<br class="">
by this commit. Gently ping :-)<br class="">
Any news on a that or any ideas you may share on how to solve it?<br class="">
<br class="">
Thanks again,<br class="">
<br class="">
Reference: <a href="http://llvm.org/bugs/show_bug.cgi?id=20641" target="_blank" class="">http://llvm.org/bugs/show_bug.cgi?id=20641</a><br class="">
<div class=""><div class=""><br class="">
On Fri, Jun 27, 2014 at 12:13 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank" class="">chandlerc@gmail.com</a>> wrote:<br class="">
> Author: chandlerc<br class="">
> Date: Fri Jun 27 10:13:01 2014<br class="">
> New Revision: 211900<br class="">
><br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=211900&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=211900&view=rev</a><br class="">
> Log:<br class="">
> Re-apply r211287: Remove support for LLVM runtime multi-threading.<br class="">
><br class="">
> I'll fix the problems in libclang and other projects in ways that don't<br class="">
> require <mutex> until we sort out the cygwin situation.<br class="">
><br class="">
> Modified:<br class="">
>     llvm/trunk/docs/ProgrammersManual.rst<br class="">
>     llvm/trunk/include/llvm-c/Core.h<br class="">
>     llvm/trunk/include/llvm/Support/ManagedStatic.h<br class="">
>     llvm/trunk/include/llvm/Support/Threading.h<br class="">
>     llvm/trunk/lib/IR/Core.cpp<br class="">
>     llvm/trunk/lib/Support/Threading.cpp<br class="">
>     llvm/trunk/unittests/Support/ManagedStatic.cpp<br class="">
><br class="">
> Modified: llvm/trunk/docs/ProgrammersManual.rst<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/docs/ProgrammersManual.rst (original)<br class="">
> +++ llvm/trunk/docs/ProgrammersManual.rst Fri Jun 27 10:13:01 2014<br class="">
> @@ -2170,46 +2170,13 @@ compiler, consider compiling LLVM and LL<br class="">
>  using the resultant compiler to build a copy of LLVM with multithreading<br class="">
>  support.<br class="">
><br class="">
> -.. _startmultithreaded:<br class="">
> -<br class="">
> -Entering and Exiting Multithreaded Mode<br class="">
> ----------------------------------------<br class="">
> -<br class="">
> -In order to properly protect its internal data structures while avoiding<br class="">
> -excessive locking overhead in the single-threaded case, the LLVM must intialize<br class="">
> -certain data structures necessary to provide guards around its internals.  To do<br class="">
> -so, the client program must invoke ``llvm_start_multithreaded()`` before making<br class="">
> -any concurrent LLVM API calls.  To subsequently tear down these structures, use<br class="">
> -the ``llvm_stop_multithreaded()`` call.  You can also use the<br class="">
> -``llvm_is_multithreaded()`` call to check the status of multithreaded mode.<br class="">
> -<br class="">
> -Note that both of these calls must be made *in isolation*.  That is to say that<br class="">
> -no other LLVM API calls may be executing at any time during the execution of<br class="">
> -``llvm_start_multithreaded()`` or ``llvm_stop_multithreaded``.  It is the<br class="">
> -client's responsibility to enforce this isolation.<br class="">
> -<br class="">
> -The return value of ``llvm_start_multithreaded()`` indicates the success or<br class="">
> -failure of the initialization.  Failure typically indicates that your copy of<br class="">
> -LLVM was built without multithreading support, typically because GCC atomic<br class="">
> -intrinsics were not found in your system compiler.  In this case, the LLVM API<br class="">
> -will not be safe for concurrent calls.  However, it *will* be safe for hosting<br class="">
> -threaded applications in the JIT, though :ref:`care must be taken<br class="">
> -<jitthreading>` to ensure that side exits and the like do not accidentally<br class="">
> -result in concurrent LLVM API calls.<br class="">
> -<br class="">
>  .. _shutdown:<br class="">
><br class="">
>  Ending Execution with ``llvm_shutdown()``<br class="">
>  -----------------------------------------<br class="">
><br class="">
>  When you are done using the LLVM APIs, you should call ``llvm_shutdown()`` to<br class="">
> -deallocate memory used for internal structures.  This will also invoke<br class="">
> -``llvm_stop_multithreaded()`` if LLVM is operating in multithreaded mode.  As<br class="">
> -such, ``llvm_shutdown()`` requires the same isolation guarantees as<br class="">
> -``llvm_stop_multithreaded()``.<br class="">
> -<br class="">
> -Note that, if you use scope-based shutdown, you can use the<br class="">
> -``llvm_shutdown_obj`` class, which calls ``llvm_shutdown()`` in its destructor.<br class="">
> +deallocate memory used for internal structures.<br class="">
><br class="">
>  .. _managedstatic:<br class="">
><br class="">
> @@ -2217,15 +2184,11 @@ Lazy Initialization with ``ManagedStatic<br class="">
>  ------------------------------------------<br class="">
><br class="">
>  ``ManagedStatic`` is a utility class in LLVM used to implement static<br class="">
> -initialization of static resources, such as the global type tables.  Before the<br class="">
> -invocation of ``llvm_shutdown()``, it implements a simple lazy initialization<br class="">
> -scheme.  Once ``llvm_start_multithreaded()`` returns, however, it uses<br class="">
> +initialization of static resources, such as the global type tables.  In a<br class="">
> +single-threaded environment, it implements a simple lazy initialization scheme.<br class="">
> +When LLVM is compiled with support for multi-threading, however, it uses<br class="">
>  double-checked locking to implement thread-safe lazy initialization.<br class="">
><br class="">
> -Note that, because no other threads are allowed to issue LLVM API calls before<br class="">
> -``llvm_start_multithreaded()`` returns, it is possible to have<br class="">
> -``ManagedStatic``\ s of ``llvm::sys::Mutex``\ s.<br class="">
> -<br class="">
>  .. _llvmcontext:<br class="">
><br class="">
>  Achieving Isolation with ``LLVMContext``<br class="">
><br class="">
> Modified: llvm/trunk/include/llvm-c/Core.h<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/include/llvm-c/Core.h (original)<br class="">
> +++ llvm/trunk/include/llvm-c/Core.h Fri Jun 27 10:13:01 2014<br class="">
> @@ -2848,16 +2848,13 @@ void LLVMDisposePassManager(LLVMPassMana<br class="">
>   * @{<br class="">
>   */<br class="">
><br class="">
> -/** Allocate and initialize structures needed to make LLVM safe for<br class="">
> -    multithreading. The return value indicates whether multithreaded<br class="">
> -    initialization succeeded. Must be executed in isolation from all<br class="">
> -    other LLVM api calls.<br class="">
> -    @see llvm::llvm_start_multithreaded */<br class="">
> +/** Deprecated: Multi-threading can only be enabled/disabled with the compile<br class="">
> +    time define LLVM_ENABLE_THREADS.  This function always returns<br class="">
> +    LLVMIsMultithreaded(). */<br class="">
>  LLVMBool LLVMStartMultithreaded(void);<br class="">
><br class="">
> -/** Deallocate structures necessary to make LLVM safe for multithreading.<br class="">
> -    Must be executed in isolation from all other LLVM api calls.<br class="">
> -    @see llvm::llvm_stop_multithreaded */<br class="">
> +/** Deprecated: Multi-threading can only be enabled/disabled with the compile<br class="">
> +    time define LLVM_ENABLE_THREADS. */<br class="">
>  void LLVMStopMultithreaded(void);<br class="">
><br class="">
>  /** Check whether LLVM is executing in thread-safe mode or not.<br class="">
><br class="">
> Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/include/llvm/Support/ManagedStatic.h (original)<br class="">
> +++ llvm/trunk/include/llvm/Support/ManagedStatic.h Fri Jun 27 10:13:01 2014<br class="">
> @@ -103,9 +103,6 @@ void llvm_shutdown();<br class="">
>  /// llvm_shutdown() when it is destroyed.<br class="">
>  struct llvm_shutdown_obj {<br class="">
>    llvm_shutdown_obj() { }<br class="">
> -  explicit llvm_shutdown_obj(bool multithreaded) {<br class="">
> -    if (multithreaded) llvm_start_multithreaded();<br class="">
> -  }<br class="">
>    ~llvm_shutdown_obj() { llvm_shutdown(); }<br class="">
>  };<br class="">
><br class="">
><br class="">
> Modified: llvm/trunk/include/llvm/Support/Threading.h<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/include/llvm/Support/Threading.h (original)<br class="">
> +++ llvm/trunk/include/llvm/Support/Threading.h Fri Jun 27 10:13:01 2014<br class="">
> @@ -7,7 +7,8 @@<br class="">
>  //<br class="">
>  //===----------------------------------------------------------------------===//<br class="">
>  //<br class="">
> -// TThis file defines llvm_start_multithreaded() and friends.<br class="">
> +// This file declares helper functions for running LLVM in a multi-threaded<br class="">
> +// environment.<br class="">
>  //<br class="">
>  //===----------------------------------------------------------------------===//<br class="">
><br class="">
> @@ -15,22 +16,8 @@<br class="">
>  #define LLVM_SUPPORT_THREADING_H<br class="">
><br class="">
>  namespace llvm {<br class="">
> -  /// llvm_start_multithreaded - Allocate and initialize structures needed to<br class="">
> -  /// make LLVM safe for multithreading.  The return value indicates whether<br class="">
> -  /// multithreaded initialization succeeded.  LLVM will still be operational<br class="">
> -  /// on "failed" return, and will still be safe for hosting threading<br class="">
> -  /// applications in the JIT, but will not be safe for concurrent calls to the<br class="">
> -  /// LLVM APIs.<br class="">
> -  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.<br class="">
> -  bool llvm_start_multithreaded();<br class="">
> -<br class="">
> -  /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM<br class="">
> -  /// safe for multithreading.<br class="">
> -  /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS.<br class="">
> -  void llvm_stop_multithreaded();<br class="">
> -<br class="">
> -  /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe<br class="">
> -  /// mode or not.<br class="">
> +  /// Returns true if LLVM is compiled with support for multi-threading, and<br class="">
> +  /// false otherwise.<br class="">
>    bool llvm_is_multithreaded();<br class="">
><br class="">
>    /// llvm_execute_on_thread - Execute the given \p UserFn on a separate<br class="">
><br class="">
> Modified: llvm/trunk/lib/IR/Core.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/lib/IR/Core.cpp (original)<br class="">
> +++ llvm/trunk/lib/IR/Core.cpp Fri Jun 27 10:13:01 2014<br class="">
> @@ -2708,11 +2708,10 @@ void LLVMDisposePassManager(LLVMPassMana<br class="">
>  /*===-- Threading ------------------------------------------------------===*/<br class="">
><br class="">
>  LLVMBool LLVMStartMultithreaded() {<br class="">
> -  return llvm_start_multithreaded();<br class="">
> +  return LLVMIsMultithreaded();<br class="">
>  }<br class="">
><br class="">
>  void LLVMStopMultithreaded() {<br class="">
> -  llvm_stop_multithreaded();<br class="">
>  }<br class="">
><br class="">
>  LLVMBool LLVMIsMultithreaded() {<br class="">
><br class="">
> Modified: llvm/trunk/lib/Support/Threading.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/lib/Support/Threading.cpp (original)<br class="">
> +++ llvm/trunk/lib/Support/Threading.cpp Fri Jun 27 10:13:01 2014<br class="">
> @@ -7,7 +7,8 @@<br class="">
>  //<br class="">
>  //===----------------------------------------------------------------------===//<br class="">
>  //<br class="">
> -// This file implements llvm_start_multithreaded() and friends.<br class="">
> +// This file defines helper functions for running LLVM in a multi-threaded<br class="">
> +// environment.<br class="">
>  //<br class="">
>  //===----------------------------------------------------------------------===//<br class="">
><br class="">
> @@ -19,38 +20,14 @@<br class="">
><br class="">
>  using namespace llvm;<br class="">
><br class="">
> -static bool multithreaded_mode = false;<br class="">
> -<br class="">
> -bool llvm::llvm_start_multithreaded() {<br class="">
> +bool llvm::llvm_is_multithreaded() {<br class="">
>  #if LLVM_ENABLE_THREADS != 0<br class="">
> -  assert(!multithreaded_mode && "Already multithreaded!");<br class="">
> -  multithreaded_mode = true;<br class="">
> -<br class="">
> -  // We fence here to ensure that all initialization is complete BEFORE we<br class="">
> -  // return from llvm_start_multithreaded().<br class="">
> -  sys::MemoryFence();<br class="">
>    return true;<br class="">
>  #else<br class="">
>    return false;<br class="">
>  #endif<br class="">
>  }<br class="">
><br class="">
> -void llvm::llvm_stop_multithreaded() {<br class="">
> -#if LLVM_ENABLE_THREADS != 0<br class="">
> -  assert(multithreaded_mode && "Not currently multithreaded!");<br class="">
> -<br class="">
> -  // We fence here to insure that all threaded operations are complete BEFORE we<br class="">
> -  // return from llvm_stop_multithreaded().<br class="">
> -  sys::MemoryFence();<br class="">
> -<br class="">
> -  multithreaded_mode = false;<br class="">
> -#endif<br class="">
> -}<br class="">
> -<br class="">
> -bool llvm::llvm_is_multithreaded() {<br class="">
> -  return multithreaded_mode;<br class="">
> -}<br class="">
> -<br class="">
>  #if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)<br class="">
>  #include <pthread.h><br class="">
><br class="">
><br class="">
> Modified: llvm/trunk/unittests/Support/ManagedStatic.cpp<br class="">
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211900&r1=211899&r2=211900&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ManagedStatic.cpp?rev=211900&r1=211899&r2=211900&view=diff</a><br class="">
> ==============================================================================<br class="">
> --- llvm/trunk/unittests/Support/ManagedStatic.cpp (original)<br class="">
> +++ llvm/trunk/unittests/Support/ManagedStatic.cpp Fri Jun 27 10:13:01 2014<br class="">
> @@ -47,7 +47,6 @@ TEST(Initialize, MultipleThreads) {<br class="">
>    void *p1 = test1::allocate_stack(a1);<br class="">
>    void *p2 = test1::allocate_stack(a2);<br class="">
><br class="">
> -  llvm_start_multithreaded();<br class="">
>    pthread_t t1, t2;<br class="">
>    pthread_create(&t1, &a1, test1::helper, nullptr);<br class="">
>    pthread_create(&t2, &a2, test1::helper, nullptr);<br class="">
> @@ -55,7 +54,6 @@ TEST(Initialize, MultipleThreads) {<br class="">
>    pthread_join(t2, nullptr);<br class="">
>    free(p1);<br class="">
>    free(p2);<br class="">
> -  llvm_stop_multithreaded();<br class="">
>  }<br class="">
>  #endif<br class="">
><br class="">
><br class="">
><br class="">
> _______________________________________________<br class="">
> llvm-commits mailing list<br class="">
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank" class="">llvm-commits@cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
<br class="">
<br class="">
<br class="">
</div></div><span class=""><font color="#888888" class="">--<br class="">
Bruno Cardoso Lopes<br class="">
<a href="http://www.brunocardoso.cc/" target="_blank" class="">http://www.brunocardoso.cc</a><br class="">
</font></span></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="">Bruno Cardoso Lopes <br class=""><a href="http://www.brunocardoso.cc/" target="_blank" class="">http://www.brunocardoso.cc</a></div>
</div>
</div></div><br class="">_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@cs.uiuc.edu" class="">llvm-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br class=""></div></blockquote></div><br class=""></div></body></html>