This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add macro LIBC_THREAD_LOCAL.
ClosedPublic

Authored by sivachandra on May 25 2023, 12:32 PM.

Details

Summary

It resolves to thread_local on all platform except for the GPUs on which
it resolves to nothing. The use of thread_local in the source code has been
replaced with the new macro.

Diff Detail

Event Timeline

sivachandra created this revision.May 25 2023, 12:32 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 25 2023, 12:32 PM
sivachandra requested review of this revision.May 25 2023, 12:32 PM
jhuber6 accepted this revision.May 25 2023, 12:44 PM

Thanks, this helps some of the implementation details.

This revision is now accepted and ready to land.May 25 2023, 12:44 PM

Please have a look at LLVM_THREAD_LOCAL macro in compiler.h. I believe there are two variants.

Please have a look at LLVM_THREAD_LOCAL macro in compiler.h. I believe there are two variants.

I think that's only important for code before C++11. Since we're always compiling with C++17 internally it shouldn't be necessary.

This revision was automatically updated to reflect the committed changes.
barannikov88 added a subscriber: barannikov88.EditedJun 17 2023, 7:08 PM

Should errno.h.def also be updated? It declares:

extern _Thread_local int __llvmlibc_errno;

while the variable is defined in libc_errno.cpp as:

LIBC_THREAD_LOCAL int __llvmlibc_errno;