[PATCH] D143708: [RISCV] Add emulated TLS supported
Vitaly Cheptsov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 11 21:55:24 PST 2023
vit9696 added a comment.
@MaskRay, we have a family of private in-house RTOSes for safety-critical application with static resource allocation (memory, threads, processes, etc). Our supported architectures include AArch64, ARM, MIPS, PowerPC, RISC-V, X86 and we have TLS in all of them. For easier certification, unified codebase, and compatibility reasons with various kinds of gcc and clang we opted with emulated TLS API. However, instead of using the implementation from builtins we went with our own, which looks roughly like this:
void* __emutls_get_address(emutls_control* control) {
return &data[control->object.index + get_thread_id() * tls_thread_size]
}
While we might add native TLS API for some architectures, our current implementation is fast enough for our needs, and the code modification process is rather costly. Also, as far as I know, most compilers do not even support TLS e.g. on MIPS without trapping, so for some processors it is not even possible to get rid of the emulated TLS without rewriting the compiler. Usually the latter is also not an option at scale.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143708/new/
https://reviews.llvm.org/D143708
More information about the llvm-commits
mailing list