<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 28, 2015 at 11:29 AM, 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">Author: chandlerc<br>
Date: Wed Jan 28 13:29:22 2015<br>
New Revision: 227352<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227352&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=227352&view=rev</a><br>
Log:<br>
[LPM] Try to work around a bug with local-dynamic TLS on PowerPC 64.<br>
<br>
Sadly, this precludes optimizing it down to initial-exec or local-exec<br>
when statically linking, and in general makes the code slower on PPC 64,<br>
but there's nothing else for it until we can arrange to produce the<br>
correct bits for the linker.<br>
<br>
Lots of thanks to Ulirch for tracking this down and Bill for working on<br>
the long-term fix to LLVM so that we can relegate this to old host<br>
clang versions.<br>
<br>
I'll be watching the PPC build bots to make sure this effectively<br>
revives them.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Support/PrettyStackTrace.cpp<br>
<br>
Modified: llvm/trunk/lib/Support/PrettyStackTrace.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PrettyStackTrace.cpp?rev=227352&r1=227351&r2=227352&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PrettyStackTrace.cpp?rev=227352&r1=227351&r2=227352&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/PrettyStackTrace.cpp (original)<br>
+++ llvm/trunk/lib/Support/PrettyStackTrace.cpp Wed Jan 28 13:29:22 2015<br>
@@ -32,12 +32,25 @@ using namespace llvm;<br>
 // thread-local variable. Some day, we should be able to use a limited subset<br>
 // of C++11's thread_local, but compilers aren't up for it today.<br>
 // FIXME: This should be moved to a Compiler.h abstraction.<br>
-#ifdef _MSC_VER // MSVC supports this with a __declspec.<br>
-static __declspec(thread) const PrettyStackTraceEntry<br>
-    *PrettyStackTraceHead = nullptr;<br>
-#else // Clang, GCC, and all compatible compilers tend to use __thread.<br>
-static __thread const PrettyStackTraceEntry *PrettyStackTraceHead = nullptr;<br>
+#ifdef _MSC_VER<br>
+// MSVC supports this with a __declspec.<br>
+#define LLVM_THREAD_LOCAL __declspec(thread)<br>
+#else<br>
+// Clang, GCC, and all compatible compilers tend to use __thread. But we need<br>
+// to work aronud a bug in the combination of Clang's compilation of<br>
+// local-dynamic TLS and the ppc64 linker relocations which we do by forcing to<br>
+// general-dynamic.<br>
+// FIXME: Make this conditional on the Clang version once this is fixed in<br>
+// top-of-tree.<br>
+#if defined(__clang__) && defined(__powerpc64__)<br>
+#define LLVM_THREAD_LOCAL __thread __attribute__((tls_model("general-dynamic")))<br>
+#else<br>
+#define LLVM_THREAD_LOCAL __thread<br>
 #endif<br>
+#endif<br></blockquote><div><br></div><div>I'd expect that #define to live in Support/Compiler.h</div><div><br></div><div>Also, shouldn't we define it to nothing if we are compiling LLVM without threads?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+static LLVM_THREAD_LOCAL const PrettyStackTraceEntry *PrettyStackTraceHead =<br>
+    nullptr;<br>
<br>
 static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){<br>
   unsigned NextID = 0;<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></div>