<div dir="ltr">> <span style="font-size:12.8px">Unfortunately it doesn't look like lli has support for emulated TLS </span><span style="font-size:12.8px">either, though that would be pretty simple to add.</span><div><span style="font-size:12.8px">As an experiment I've `llvm::createLowerEmuTLSPass` into lli which added @__emutls_v.x and @__emutls_v.t.</span></div><div><span style="font-size:12.8px">However i didn't have any </span><span style="font-size:12.8px">__emultls_get_address calls in my IR.</span></div><div><span style="font-size:12.8px">Is there a llvm pass or compiler-flag that replaces thread_locals with appropriate  __emultls_get_address calls ?</span></div><div><br></div><img width="0" height="0" class="mailtrack-img" src="https://mailtrack.io/trace/mail/3932cbeb61126e17cd3db5a7d6a9e084707d3692.png?u=931501"></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-08 14:53 GMT+00:00 Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 8 February 2017 at 04:57, Gaetano Checinski<br>
<span class=""><<a href="mailto:gaetano.checinski@gmail.com">gaetano.checinski@gmail.com</a>> wrote:<br>
> What exactly do the compiler flags`-femulated-tls` and `tls-model` do ?<br>
> Why does tls-emulation not solve the problem ?<br>
<br>
</span>It requires runtime support, specifically the __emultls_get_address<br>
function by the looks of it. That's not available on all platforms<br>
(it's not supplied by macOS for example) and is likely to be slower<br>
than native TLS if it is.<br>
<span class=""><br>
> Looking at the generated IR, it seems not to remove thread_local variable declarations.<br>
> What is the reasoning behind that ?<br>
<br>
</span>Using "-emit-llvm" doesn't actually print out the very final form of<br>
the LLVM IR. There are a few passes that run on the IR but are<br>
considered part of the final "CodeGen" phase. As a rule of thumb those<br>
are passes that are required for correctness reasons, in this case<br>
because without the LowerEmuTLS.cpp pass affected backends couldn't<br>
handle TLS constructs.<br>
<br>
Unfortunately it doesn't look like lli has support for emulated TLS<br>
either, though that would be pretty simple to add.<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>