<div dir="ltr"><div>Reid,<br></div><div><br></div><div>Do you mean changing the following functions</div><div>  TargetMachine::getTLSModel(const GlobalValue *GV)</div><div>  getSelectedTLSModel(const GlobalValue *GV)</div><div>to return TLSModel::emulated when -femulated-tls is true?</div><div><br></div><div>The main difference from my current patch will be the hiding of C/C++ attribute tls_model("emulated") and IR thread_local(emulated) attribute, right?</div><div><br></div><div>Here is my understanding of the suggested changes:</div><div><br></div><div>My current patch <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10522-236fcff2f8&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=fOnoKbVlbSaxsDlyiDiuhLCwUiqbenw-yugpTp-fB38&s=MhM7VOQKgd2a0QCkVGV780b-vzT033SWLwCz9PVv24s&e=">http://reviews.llvm.org/D10522#6fcff2f8</a></div><div>changed getSelectedTLSModel to return TLSModel::emulated</div><div>if a global value is marked as such.</div><div>(a) The mark is IR thread_local(emulated) attribute.</div><div>(b) Clang sets this attribute as default for __thread variables when -ftls-model=emulated.</div><div>(c) It is valid to write IL with thread_local(emulated) attribute, or C/C++ code with attribute tls_model("emulated").</div><div><br></div><div>New suggested changes:</div><div>(a) Do not add -ftls-model=emulated.</div><div>(b) Add -femulated-tls flag, which sets up some TargetMachine internal flag.</div><div>(c) No C/C++ attribute tls_model("emulated") nor IR thread_local(emulated) attribute, but there is internal TLSModel::emulated</div><div>(d) TargetMachine::getTLSModel and getSelectedTLSModel returns TLSModel::emulated when -femulated-tls is true. This overwrites the thread_local(*) attributes specified for the variable in IR.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 15, 2015 at 8:48 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Jul 14, 2015 at 5:22 PM, Chih-Hung Hsieh <span dir="ltr"><<a href="mailto:chh@google.com" target="_blank">chh@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">chh added a comment.<br>
<br>
So in IR, a global variable can have string attributes like<br>
<br>
  thread_local emulated-tls<br>
  thread_local(localdynamic) emulated-tls<br>
  thread_local(initialexec) emulated-tls<br>
  thread_local(localexec) emulated-tls<br>
<br>
I can give it a try.<br>
Not sure yet if that will have shorter or longer patch.<br></blockquote><div><br></div></span><div>Sorry, that looks like it was bad advice. The LLVM GlobalVariable class doesn't appear to support attributes. In that case, it's probably better to make it global and let it be controlled by the TargetMachine.</div><div><br></div><div>Ultimately, I think the patches will be smaller because we shouldn't need to change IR serialization.</div></div></div></div>
</blockquote></div><br></div>