-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Thread-Local Storage Descriptors (TLSDESC) #94
Comments
Seems like a good idea, though a big chunk of work to specify and implement. Any chance you're volunteering? :) |
I'm still getting my feet wet with riscv toolchain (tracking the progress of musl-riscv, reading |
One note based on comments from sorear on |
Indeed, |
It looks like no progress has been made since this was filed, but I'd like to see this to happen. Compared to the current TLS model, TLSDESC is strictly better; it's more generic, more efficient and simpler. |
I don’t think there’s any disagreement on the technical merits. Someone needs to volunteer to do the work. Many of the folks who work on the toolchain are doing the things their employers think are the most pressing, and this one doesn’t seem to be reaching the top of anyone’s list. So, unless someone volunteers to do it out of the goodness of their hearts, it’ll probably be a few more years. |
I understand that. I'm currently busy working on my mold linker (which by the way supports RISC-V), so I don't have a bandwidth to take this one, but if someone wants to take this, I'm happy to support. |
@rui314 mold looks like a great project! |
I'm planning to prototype on an implementation (with draft spec) in the following weeks. I'll keep you updated when I make progress. |
Cool! |
I'm proud to say that this effort is sponsored by the mold project. We are interested in not only implementing but also improving the RISC-V psABI. |
@rui314 Has there been any progress on this? Are there thing we can do to help? |
@ishitatsuyuki is working on this. |
Hi, sorry for the silence, the last few weeks have been a little busy due to IRL matters but I’m still working on this. Currently trying to get a prototype working with the GNU toolchain. |
No need for apologies, open source contributors shouldn't feel pressured to volunteer more time than they already do. So thanks for working on this. Are there things we could do to expedite your work? For instance, we could help prototype things on the LLVM side, or help with code review (when ready). It may also be helpful to sketch out some of the details in this thread, like the set of registers you plan to use (probably just |
The instruction sequence I'm thinking right now is something like below. It mirrors the AArch64 sequence, thanks to the fact that
Relocations: More or less same as AArch64, with the exception that immediates in both Registers: Only Relaxation: 4 instructions should be enough to fit both IE and LE sequences mentioned in #122. But see below for fusing the load/store offset. Remarks and design questions:
|
@rui314 @ishitatsuyuki really excite to hear you are planing on this!
IIUC
I would prefer to allow compiler to interleave the sequence if possible, and I am curious, does here benefit if we have fixing code sequence for the linker implementation side? |
Rui suggested that the registers in the instruction sequence is unnecessarily constrained, though, so I'm thinking of relaxing it to something like this, where
Still, I think maybe the instruction sequence for TLSDESC should be kept uncompressed, otherwise this could potentially significantly make relaxation harder by restricting the instructions that it can be replaced with.
On second thought I think fixing the code sequence is not really necessary, and we probably want to give compiler the freedom of scheduling (and register allocation as mentioned above). So in the draft I'm writing right now I'll go without the scheduling restriction. In other news, I'm currently working on a draft version of spec; it won't be ready for merge until I implement the prototype, but a draft PR should be a better place to discuss this. |
We should definitely not use a register other than |
For |
The spec draft is available at #373. Let me know about your thoughts. |
riscv-non-isa/riscv-elf-psabi-doc#94 was merged. Bug: google/android-riscv64#3 Test: treehugger Change-Id: Ifc0c4d7408367f0372cec969d4ee6f84699bee30
Bug: riscv-non-isa/riscv-elf-psabi-doc#94 Test: treehugger Change-Id: I1580686c8381be7dfdb5d7684934a176e0d11d77
TLSDESC (
-mtls-dialect=gnu2
) improves traditional General Dynamic and Local Dynamic TLS models (-mtls-dialect=gnu
). In the most common case that TLS variables are defined in initially-loaded modules, it simplifies the work in__tls_get_addr
and (probably more importantly) switches to a custom calling convention that doesn't clobber any register ("preserve any registers they modify"). This speedup is significant.The linker may relax TLSDESC code sequence to Initial Exec (targeting an executable, the symbol is preemptable) or Local Exec (target an executable, the symbol is non-preemptable) if applicable.
The initial (static) and outstanding (dynamic) relocation types for TLSDESC have to be defined, as well as how static relocation types are relaxed to Initial Exec and Local Exec models.
TLSDESC is currently available on x86, x86-64, arm and aarch64.
x86: https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-x86.txt
ARM: https://www.fsfla.org/~lxoliva/writeups/TLS/RFC-TLSDESC-ARM.txt (the published paper was referenced by ELF for the Arm 64-bit Architecture (AArch64) and ARM 32-bit)
As I understand it, TLSDESC is a strict improvement, so it might be worth defaulting to TLSDESC and probably deprecating relocation types for General Dynamic/Local Dynamic.
The text was updated successfully, but these errors were encountered: