JITted code and thread-local storage

Hello,

Am I right in thinking that MCJIT doesn't support thread-local
variables (at least not on Linux x86-64)?

Is there any plan or pending PR to support it (either in MCJIT or in
ORC)?

Thank you,

Regards

Antoine.

/cc Lang Hames

I had tried this in https://reviews.llvm.org/D8815, but we’ve since switched to a home grown TLS implementation, so I currently don’t have a need for this.

We use GS based addressing in our code just fine. We have a home grown version of TLS, but I believe the principal mechanisms needed for the Linux x86-64 version are similar. The key thing you need is to use the right address space (256 = GS, 257 = FS IRC) when describing the memory locations.

Philip

Thanks for the answers, everyone.

In the end, we opted to not use the JIT for this. We defer to some C
helpers, which exploit the C compiler and runtime linker's support for
thread-local variables. This buys us portability without any hassle (at
the cost of an additional function call, though).

Regards

Antoine.

Hi Antoine,

I don’t believe there’s any ORC PR for this yet.

Keno - your patch allowed JIT’d code to access TLVs defined in the host process, right? That would be nice to have eventually, but we’re probably best off requiring calls to accessors in the host for now.

I’d like to see support for TLV definitions in JIT’d code, but I haven’t been able to find time to work on that one yet.

Cheers,
Lang.

Keno - your patch allowed JIT'd code to access TLVs defined in the host process, right? That would be nice to have eventually, but we're probably best off requiring calls to accessors in the host for now.

correct