<div dir="ltr">I tried this once and ran into some difficulty, because before this change, the Mutex is a pointer which null is an expected value if llvm_start_multithreaded has not been called.  So the function would have to return a pointer to the mutex.  That would require changing MutexGuard to take a pointer instead of a reference, which would generate a ton of churn.<div>
<br></div><div>I'll have another stab at it and see if there's a way to do it in a way that has very little churn and still contributes to this change as well.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Jun 13, 2014 at 2:55 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One more thing to split out, and I think this will actually look good.<br>
<br>
================<br>
Comment at: lib/Support/ManagedStatic.cpp:27<br>
@@ -25,3 +26,3 @@<br>
   if (llvm_is_multithreaded()) {<br>
-    llvm_acquire_global_lock();<br>
+    llvm::MutexGuard Lock(llvm_get_global_lock());<br>
<br>
----------------<br>
This (and the related change to the interface) is the other unrelated cleanup that I would like to see separated out from the change which has policy effect.<br>
<br>
Consider, if we need to revert the runtime control of multithreading for a brief period because something breaks, we shouldn't also lose this cleanup change.<br>
<br>
<a href="http://reviews.llvm.org/D4139" target="_blank">http://reviews.llvm.org/D4139</a><br>
<br>
<br>
</blockquote></div><br></div>