diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-02-29 17:08:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 17:08:37 +0100 |
| commit | eea8ceed54033b7967fe9e7d4c26d2a0942ef722 (patch) | |
| tree | 084254649e2fda2d54d52c5dbc1ab7a3fc90d708 /compiler/rustc_errors/src | |
| parent | 2e0a26a32a51faba018d70310869e73b2743c959 (diff) | |
| parent | ad4c4f4654bf78bb51638e58a9c418afcdd6ee15 (diff) | |
| download | rust-eea8ceed54033b7967fe9e7d4c26d2a0942ef722.tar.gz rust-eea8ceed54033b7967fe9e7d4c26d2a0942ef722.zip | |
Rollup merge of #121596 - ChrisDenton:tls, r=joboet
Use volatile access instead of `#[used]` for `on_tls_callback` The first commit adds a volatile load of `p_thread_callback` when registering a dtor so that the compiler knows if the callback is used or not. I don't believe the added volatile instruction is otherwise significant in the context. In my testing using the volatile load allowed the compiler to correctly reason about whether `on_tls_callback` is used or not, allowing it to be omitted entirely in some cases. Admittedly it usually is used due to `Thread` but that can be avoided (e.g. in DLLs or with custom entry points that avoid the offending APIs). Ideally this would be something the compiler could help a bit more with so we didn't have to use tricks like `#[used]` or volatile. But alas. I also used this as an opportunity to clean up the `unused` lints which I don't think serve a purpose any more. The second commit removes the volatile load of `_tls_used` with `#cfg[target_thread_local]` because `#[thread_local]` already implies it. And if it ever didn't then `#[thread_local]` would be broken when there aren't any dtors.
Diffstat (limited to 'compiler/rustc_errors/src')
0 files changed, 0 insertions, 0 deletions
