Closed
Description
Thread local accesses are a runtime operation, even if LLVM shims them to appear like normal static accesses. We should encode this runtime-ness in MIR and translate them back to the llvm static accesses in the llvm backend. The other backends (miri, cranelift) then have an easier life at doing the right thing ^TM.
Activity
eddyb commentedon Apr 2, 2020
Copying my #70684 (comment) here
(note "the address of a
#[thread_local]
static
", not "access", the address itself is runtime):As I suggested elsewhere, I believe
#[thread_local]
static
s should have their own separate access mechanism, probably their ownRvalue
(or we could start extending whatRvalue::{Ref,RawPtr}
can borrow).That's because getting the address of a
#[thread_local]
static
is a fundamentally runtime operation, and LLVM reusing the same syntax as for regularstatic
s, is in the wrong here.vakaras commentedon Apr 2, 2020
@eddyb @oli-obk
Do you have an estimate how much effort this would require? If it is doable in a day or two and you could give me the mentoring instructions, I could try implementing this.
eddyb commentedon Apr 2, 2020
No idea, cc @matthewjasper @wesleywiser @spastorino
(I forget who did the move to constant pointers for statics)thanks @bjorn3!bjorn3 commentedon Apr 2, 2020
That was done in #67000.
#[thread_local] static mut
is allowed to have'static
lifetime #54366Auto merge of rust-lang#71192 - oli-obk:eager_alloc_id_canonicalizati…