about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-16 16:36:46 +0000
committerbors <bors@rust-lang.org>2021-04-16 16:36:46 +0000
commit0cc00c48d2c8f7344028cf007d1ee551b886b602 (patch)
tree3cc34021312b1737f3ac1fb268a9e09dad757093 /compiler/rustc_codegen_llvm/src/llvm_util.rs
parent2faef12b656d40522ca3b4a53b36299b4364e717 (diff)
parentc6eea222a9cafeeeedfa1767232328710b350447 (diff)
downloadrust-0cc00c48d2c8f7344028cf007d1ee551b886b602.tar.gz
rust-0cc00c48d2c8f7344028cf007d1ee551b886b602.zip
Auto merge of #83416 - alexcrichton:const-thread-local, r=sfackler
std: Add a variant of thread locals with const init

This commit adds a variant of the `thread_local!` macro as a new
`thread_local_const_init!` macro which requires that the initialization
expression is constant (e.g. could be stuck into a `const` if so
desired). This form of thread local allows for a more efficient
implementation of `LocalKey::with` both if the value has a destructor
and if it doesn't. If the value doesn't have a destructor then `with`
should desugar to exactly as-if you use `#[thread_local]` given
sufficient inlining.

The purpose of this new form of thread locals is to precisely be
equivalent to `#[thread_local]` on platforms where possible for values
which fit the bill (those without destructors). This should help close
the gap in performance between `thread_local!`, which is safe, relative
to `#[thread_local]`, which is not easy to use in a portable fashion.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions