[LLVMdev] [Patch, RFC] Re: Adding support for explicitly specified TLS models (PR9788)
Hans Wennborg
hans at chromium.org
Fri Jun 8 00:34:55 PDT 2012
On Mon, Jun 4, 2012 at 3:49 PM, Hans Wennborg <hans at chromium.org> wrote:
> Reviving this thread with a patch!
>
> And some comments inline.
>
> Please take a look and let me know what you think.
>
> - Hans
>
> On Wed, Apr 25, 2012 at 12:39 PM, Hans Wennborg <hans at chromium.org> wrote:
>> Hi all,
>>
>> I would like to hear your thoughts on adding support for extending the
>> IR to allow for explicitly selecting which model to use for
>> thread-local storage of a variable.
>>
>> The motivation is to allow Clang to support the "tls_model" variable
>> attribute [1], as requested in PR9788.
>
> This enables better performance for some code. For example, TCMalloc
> [3] would like to use the initial-exec model, because it's faster.
>
>> The idea would be to extend the IR to allow an optional TLS-model
>> argument to the thread_local attribute, like this:
>>
>> @x = thread_local(initialexec) global i32 42
>>
>> Just as it is illegal to specify thread_local for a target that
>> doesn't support it, specifying a TLS model that isn't supported by the
>> target would be illegal. If a model is not specified, the target gets
>> to choose the appropriate model, as it does today.
>
> As discussed on the original thread, I've changed my mind here. I
> don't think there should be any error (or warning) for specifying a
> model that isn't supported by a particular target. The target should
> just fall back to whatever model it supports.
>
>> The models in question are described in Section 4 of [2]. As far as I
>> understand, LLVM supports the following models:
>>
>> - X86/ELF: general dynamic, initial exec (but not for PIC code?), local exec
>
> It now supports all four models.
>
>> - ARM/ELF: general dynamic, local exec
>
> And also initial exec.
>
>> - Mips: general dynamic, local dynamic, initial exec, local exec
>> - X86 for Darwin and Windows, and XCore, do their own thing
>> - The other targets don't support thread-local storage
>>
>> [1] http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Variable-Attributes.html#index-g_t_0040code_007btls_005fmodel_007d-attribute-1797
>> [2] http://www.akkadia.org/drepper/tls.pdf
>
> [3] http://code.google.com/searchframe#BGeH2W13jNw/trunk/src/thread_cache.h&l=257
Ping?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tls_models.diff
Type: application/octet-stream
Size: 36638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120608/b2aa1469/attachment.obj>
More information about the llvm-dev
mailing list