TLS and x86-64 fs:

Cecil Ward cecil at cecilward.com
Wed Jun 28 23:41:34 UTC 2023


On Wednesday, 28 June 2023 at 23:39:43 UTC, Cecil Ward wrote:
> It seems that in x86-64 Linux (which I think is what 
> godbolt.org uses - is that correct?), LDC emits a function call 
> to get the address of your TLS static base. GDC seems to be 
> vastly more efficient as it simply uses an fs: segment override 
> and apart from that accesses the RAM directly. I don’t know 
> what is happening if someone takes the address of a TLS static 
> and mixes it with a comparison or pointer arithmetic with say 
> an alloc cell or address in one of the stacks. How that works 
> is a GDC question.
>
> I wonder why the difference in method between the compilers ? 
> Could LDC steal the GDC tech here in order to get much more 
> speed ?

Perhaps I should try taking the address of a TLS static with GDC 
and taking a look at its value?


More information about the digitalmars-d-ldc mailing list