[llvm-commits] [LLVMdev] [Patch, RFC] Re: Adding support for explicitly specified TLS models (PR9788)

Rafael Espíndola rafael.espindola at gmail.com
Thu Jun 14 13:33:31 PDT 2012


> Right, that's a good point.
>
> On i386 Linux, the following code,
>
>  static __thread int x[100000];
>  int* get_x() { return x; }
>
> compiled with "clang -shared a.c -o a.so" won't be possible do dlopen.

I get exactly the same result with gcc 4.7 with and without
-ftls-model=global-dynamic:

movq %gs:0, %eax
addl $x at ntpoff, %eax

> Rafael, I think your argument has been that if we're unsure if there
> is any reason to strictly preserve the user's choice, we should just
> let LLVM choose a better model (and not have to specify any difference
> between the "default" and global-dynamic models in the IR).

Not quiet. My main argument is that we are not adding value, since the
linker also does optimizations and the ELF format doesn't list if the
choice of model was explicit or not.

Secondary arguments for going without a "default" value are:

* It is much easier to add it if we find that we do need it than it is
to remove it if we convince ourselves that it is redundant.
* It adds complexity. For example, LLVM would have to distinguish
being run in "compiler mode" versus "linker mode", as the optimization
is clearly valid at LTO time even if we find a reason for not doing it
during compilation.

>
> Thanks,
> Hans

Cheers,
Rafael




More information about the llvm-commits mailing list