[PATCH] D10524: Clang/driver: emulated TLS mode.

Chih-hung Hsieh chh at google.com
Wed Jul 15 10:41:20 PDT 2015


Reid,

Do you mean changing the following functions
  TargetMachine::getTLSModel(const GlobalValue *GV)
  getSelectedTLSModel(const GlobalValue *GV)
to return TLSModel::emulated when -femulated-tls is true?

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?

Here is my understanding of the suggested changes:

My current patch http://reviews.llvm.org/D10522#6fcff2f8
changed getSelectedTLSModel to return TLSModel::emulated
if a global value is marked as such.
(a) The mark is IR thread_local(emulated) attribute.
(b) Clang sets this attribute as default for __thread variables when
-ftls-model=emulated.
(c) It is valid to write IL with thread_local(emulated) attribute, or C/C++
code with attribute tls_model("emulated").

New suggested changes:
(a) Do not add -ftls-model=emulated.
(b) Add -femulated-tls flag, which sets up some TargetMachine internal flag.
(c) No C/C++ attribute tls_model("emulated") nor IR thread_local(emulated)
attribute, but there is internal TLSModel::emulated
(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.


On Wed, Jul 15, 2015 at 8:48 AM, Reid Kleckner <rnk at google.com> wrote:

> On Tue, Jul 14, 2015 at 5:22 PM, Chih-Hung Hsieh <chh at google.com> wrote:
>
>> chh added a comment.
>>
>> So in IR, a global variable can have string attributes like
>>
>>   thread_local emulated-tls
>>   thread_local(localdynamic) emulated-tls
>>   thread_local(initialexec) emulated-tls
>>   thread_local(localexec) emulated-tls
>>
>> I can give it a try.
>> Not sure yet if that will have shorter or longer patch.
>>
>
> 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.
>
> Ultimately, I think the patches will be smaller because we shouldn't need
> to change IR serialization.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150715/eeadc263/attachment.html>


More information about the llvm-commits mailing list