[llvm-dev] Is there some sort of "@llvm.thread_ctors."?

Yafei Liu via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 9 03:47:31 PST 2020


We know that in C++, the constructor of a static member will get called
when the program starts up. I checked the generated IR code and found this
is implemented by defining a __cxx_global_var_init() function and marked it
as section ".text.startup" and assign it to @llvm.global_ctors.

We also know that in C++, the constructor of a static thread_local member
will *not* get called when the program starts, but the first time this
member is used, I also checked the IR code, this is implemented by calling
it's constructor at the usage, and then call __cxa_thread_atexit to
register it's destructor.

Now I want to add thread_local feature to my own language, and I want my
thread_local member acts simlar like a static member, that is,  when a new
thread is created, the constructors of thread_local members will
automatically get called, instead get called when used?

I read the LLVM Language Reference Manual, but it doesn't talk much
in Thread Local Storage Models.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200109/8099601d/attachment.html>


More information about the llvm-dev mailing list