[llvm-commits] [PATCH] Implement local-dynamic TLS model for x86 (PR3985)

Hans Wennborg hans at chromium.org
Fri Jun 1 09:29:45 PDT 2012


On Fri, Jun 1, 2012 at 3:18 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> Comments welcome :)
>
> Thanks for working on this and sorry for taking so long to look at it.
> I have not worked on TLS ever since creating that FIXME :-)
>
> The description of MO_TLSLD{M} is not very clear. It effectively
> evaluates the to a base address that is the same for every symbol in a
> module, right?

Heh, I copy-pasted the comment from the other TLS-related MOs, which
all say the same thing :) I've updated the descriptions of the ones I
add, and I will follow up with a patch to update the others too.

> With this patch we create a local dynamic access even if there is a
> single __thread variable in use in a function, right? That is probably
> OK, but a test documenting it and maybe a FIXME to optimize it back to
> general dynamic would be nice (or if you benchmarked it to be better,
> note so on the test).

I've expanded a test to make it explicit, and added a FIXME.

> If you put TLS_base_addr32 after TLS_addr32 you can reused the "let ..
> in", no? Same for the 64 bit version.

Done.

> Can you add the testcase in PR3985? I noticed that the code we produce
> is still not as good as GCC as we have an extra copy. That is probably
> a register allocator deficiency, but the testcase is a good home for a
> FIXME about it.

As discussed on IRC, it's the same amount of copies.

GCC copies %rax to %rdx so that it can use %eax in the movl and addl,
whereas LLVM does the addition into %ecx and copies that to %eax
afterwards.

> LGTM with those changes.

Thanks! Landed in r157818.

 - Hans




More information about the llvm-commits mailing list