[llvm-dev] Use of the C++ standard library in XRay compiler-rt

Chandler Carruth via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 14 17:38:41 PDT 2017


On Tue, Mar 14, 2017 at 5:34 PM Dean Michael Berris via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On 13 Mar 2017, at 15:39, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> One thing we rely on heavily on in the FDR mode implementation is C++'s
> `thread_local` keyword. I'm not sure what that entails runtime-wise (does
> it need pthreads? or something else?) but I'm sure a functional replacement
> would be alright too.
>
>
> No doubt we can find some common API for that, I'd guess tsan probably has
> already had to figure out things like that.
>
>
> I suspect I'm more worried about costs rather than APIs. I've learned a
> while back that system-provided TLS functionality isn't as good as
> compiler-provided (and system/platform-specific) TLS implementations.
>

I think what you want here (see David Chisnall's post as well) is
essentially the GNU extension '__thread' which both Clang and GCC have
strong support for.

It works like thread_local except that it has the kind of restrictions
David mentions so that it doesn't become a runtime burden.

(Note that thread_local, if it can at all require dynamic initialization,
ends up quite bad even when the constructor is "trivial". sadly....)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170315/1246d381/attachment.html>


More information about the llvm-dev mailing list