Skip to content
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

Should generate llvm.threadlocal.address for TLS accesses #136044

Open
nikic opened this issue Jan 25, 2025 · 0 comments · May be fixed by #139385
Open

Should generate llvm.threadlocal.address for TLS accesses #136044

nikic opened this issue Jan 25, 2025 · 0 comments · May be fixed by #139385
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikic
Copy link
Contributor

nikic commented Jan 25, 2025

See https://llvm.org/docs/LangRef.html#llvm-threadlocal-address-intrinsic. Instead of directly accessing the global, the result of @llvm.threadlocal.address(ptr @g) should be accessed.

This is required for correctness when using LLVM coroutines (not relevant for Rust), but it should also improve codegen in some cases because it will allow CSE/LICM of the TLS address calculation.

@nikic nikic added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. labels Jan 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 25, 2025
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-thread-locals Area: Thread local storage (TLS) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-thread-locals Area: Thread local storage (TLS) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants