[llvm] r227352 - [LPM] Try to work around a bug with local-dynamic TLS on PowerPC 64.

David Majnemer david.majnemer at gmail.com
Wed Jan 28 11:51:49 PST 2015


On Wed, Jan 28, 2015 at 11:29 AM, Chandler Carruth <chandlerc at gmail.com>
wrote:

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

I'd expect that #define to live in Support/Compiler.h

Also, shouldn't we define it to nothing if we are compiling LLVM without
threads?


> +
> +static LLVM_THREAD_LOCAL const PrettyStackTraceEntry
> *PrettyStackTraceHead =
> +    nullptr;
>
>  static unsigned PrintStack(const PrettyStackTraceEntry *Entry,
> raw_ostream &OS){
>    unsigned NextID = 0;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150128/47fa9d55/attachment.html>


More information about the llvm-commits mailing list