<div dir="ltr">Sorry, what i meant by my comment about the Host layer is that I suspect we don't run the risk of the problem becoming widespread enough that it will have noticeable performance impact on startup time.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 1:35 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"><div dir="ltr">Hi Greg,<div><br></div><div>MSVC doesn't have thread-safe function local statics, which is why I opted to use global statics.  I suspect most statics will be in the Host layer, and as such we don't run the risk of incurring their penalty all over.  If it's just a matter of silencing a warning, can we silence it at the compiler level instead?  Or are you concerned about the performance overhead of the global constructors?</div>

</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 10:00 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gclayton<br>
Date: Wed Aug 20 12:00:21 2014<br>
New Revision: 216080<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=216080&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=216080&view=rev</a><br>
Log:<br>
Avoid global contstructors and place static variables inside classes as static local variables and remove the static ivars. Subclasses should use the accessor functions.<br>
<br>
<br>
Modified:<br>
    lldb/trunk/include/lldb/Host/HostInfoBase.h<br>
    lldb/trunk/source/Host/common/HostInfoBase.cpp<br>
<br>
Modified: lldb/trunk/include/lldb/Host/HostInfoBase.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostInfoBase.h?rev=216080&r1=216079&r2=216080&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostInfoBase.h?rev=216080&r1=216079&r2=216080&view=diff</a><br>


==============================================================================<br>
--- lldb/trunk/include/lldb/Host/HostInfoBase.h (original)<br>
+++ lldb/trunk/include/lldb/Host/HostInfoBase.h Wed Aug 20 12:00:21 2014<br>
@@ -80,14 +80,6 @@ class HostInfoBase<br>
<br>
   protected:<br>
     static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);<br>
-<br>
-    static uint32_t m_number_cpus;<br>
-    static std::string m_vendor_string;<br>
-    static std::string m_os_string;<br>
-    static std::string m_host_triple;<br>
-<br>
-    static ArchSpec m_host_arch_32;<br>
-    static ArchSpec m_host_arch_64;<br>
 };<br>
 }<br>
<br>
<br>
Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=216080&r1=216079&r2=216080&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=216080&r1=216079&r2=216080&view=diff</a><br>


==============================================================================<br>
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)<br>
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Wed Aug 20 12:00:21 2014<br>
@@ -22,85 +22,86 @@<br>
 using namespace lldb;<br>
 using namespace lldb_private;<br>
<br>
-uint32_t HostInfoBase::m_number_cpus = 0;<br>
-std::string HostInfoBase::m_vendor_string;<br>
-std::string HostInfoBase::m_os_string;<br>
-std::string HostInfoBase::m_host_triple;<br>
-ArchSpec HostInfoBase::m_host_arch_32;<br>
-ArchSpec HostInfoBase::m_host_arch_64;<br>
<br>
 uint32_t<br>
 HostInfoBase::GetNumberCPUS()<br>
 {<br>
     static bool is_initialized = false;<br>
+    uint32_t g_number_cpus = 0;<br>
     if (!is_initialized)<br>
     {<br>
-        m_number_cpus = std::thread::hardware_concurrency();<br>
+        g_number_cpus = std::thread::hardware_concurrency();<br>
         is_initialized = true;<br>
     }<br>
<br>
-    return m_number_cpus;<br>
+    return g_number_cpus;<br>
 }<br>
<br>
 llvm::StringRef<br>
 HostInfoBase::GetVendorString()<br>
 {<br>
     static bool is_initialized = false;<br>
+    std::string g_vendor_string;<br>
     if (!is_initialized)<br>
     {<br>
         const ArchSpec &host_arch = HostInfo::GetArchitecture();<br>
         const llvm::StringRef &str_ref = host_arch.GetTriple().getVendorName();<br>
-        m_vendor_string.assign(str_ref.begin(), str_ref.end());<br>
+        g_vendor_string.assign(str_ref.begin(), str_ref.end());<br>
         is_initialized = true;<br>
     }<br>
-    return m_vendor_string;<br>
+    return llvm::StringRef(g_vendor_string);<br>
 }<br>
<br>
 llvm::StringRef<br>
 HostInfoBase::GetOSString()<br>
 {<br>
     static bool is_initialized = false;<br>
+    std::string g_os_string;<br>
     if (!is_initialized)<br>
     {<br>
         const ArchSpec &host_arch = HostInfo::GetArchitecture();<br>
         const llvm::StringRef &str_ref = host_arch.GetTriple().getOSName();<br>
-        m_os_string.assign(str_ref.begin(), str_ref.end());<br>
+        g_os_string.assign(str_ref.begin(), str_ref.end());<br>
         is_initialized = true;<br>
     }<br>
-    return m_os_string;<br>
+    return llvm::StringRef(g_os_string);<br>
 }<br>
<br>
 llvm::StringRef<br>
 HostInfoBase::GetTargetTriple()<br>
 {<br>
     static bool is_initialized = false;<br>
+    std::string g_host_triple;<br>
     if (!is_initialized)<br>
     {<br>
         const ArchSpec &host_arch = HostInfo::GetArchitecture();<br>
-        m_host_triple = host_arch.GetTriple().getTriple();<br>
+        g_host_triple = host_arch.GetTriple().getTriple();<br>
         is_initialized = true;<br>
     }<br>
-    return m_host_triple;<br>
+    return g_host_triple;<br>
 }<br>
<br>
 const ArchSpec &<br>
 HostInfoBase::GetArchitecture(ArchitectureKind arch_kind)<br>
 {<br>
     static bool is_initialized = false;<br>
+    static ArchSpec g_host_arch_32;<br>
+    static ArchSpec g_host_arch_64;<br>
+<br>
     if (!is_initialized)<br>
     {<br>
-        HostInfo::ComputeHostArchitectureSupport(m_host_arch_32, m_host_arch_64);<br>
+        HostInfo::ComputeHostArchitectureSupport(g_host_arch_32, g_host_arch_64);<br>
         is_initialized = true;<br>
     }<br>
<br>
     // If an explicit 32 or 64-bit architecture was requested, return that.<br>
     if (arch_kind == eArchKind32)<br>
-        return m_host_arch_32;<br>
+        return g_host_arch_32;<br>
     if (arch_kind == eArchKind64)<br>
-        return m_host_arch_64;<br>
+        return g_host_arch_64;<br>
<br>
     // Otherwise prefer the 64-bit architecture if it is valid.<br>
-    return (m_host_arch_64.IsValid()) ? m_host_arch_64 : m_host_arch_32;<br>
+    return (g_host_arch_64.IsValid()) ? g_host_arch_64 : g_host_arch_32;<br>
 }<br>
<br>
 void<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>