[cxx-abi-dev] thread_local summary

John McCall rjmccall at apple.com
Tue Oct 2 17:40:01 UTC 2012


On Oct 2, 2012, at 5:52 AM, Jason Merrill wrote:
> On 10/02/2012 01:00 AM, Dennis Handly wrote:
>>> From: Jason Merrill <jason at redhat.com>
>>> I'm currently mangling the init and wrapper functions as normal
>>> functions with a function name of _TH <object name> or _TW <object
>>> name>, respectively.  I've thought about dropping the function type from
>>> the mangling, but don't have a strong opinion.
>> 
>> So is this going to be added to the mangling specs?
> 
> Yes, that's the idea.

FWIW, this all seems basically reasonable to me, at least for the most
general case.  I think we're going to need a way to declare that a variable
doesn't have dynamic initialization — mandating a call basically ruins the
more efficient TLS models.

Formally, the wrapper function doesn't seem to be ABI here — it's just a
recommendation for saving code size and relocations at the access site.

Taking the address of a function leads to pretty awful code.  I suggest that
we guarantee the existence of an init function in obvious cases, like when
the type is non-POD.  In this case, we can just call the init function, right?

For mangling, I think we should just follow the pattern for guard variables —
pick some 2-character prefix and drop the function type.  So something
like _ZTH6my_var.

It looks like static data members of class templates fall out naturally here,
with the init function becoming COMDAT.

John.


More information about the cxx-abi-dev mailing list