Skip to content

Make thread local accesses an Rvalue in MIR #70685

Closed
@oli-obk

Description

@oli-obk
Contributor

#70598 (comment)

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.

cc @bjorn3 @eddyb @vakaras

Activity

eddyb

eddyb commented on Apr 2, 2020

@eddyb
Member

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] statics should have their own separate access mechanism, probably their own Rvalue (or we could start extending what Rvalue::{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 regular statics, is in the wrong here.

added
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
A-thread-localsArea: Thread local storage (TLS)
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 2, 2020
vakaras

vakaras commented on Apr 2, 2020

@vakaras
Contributor

@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

eddyb commented on Apr 2, 2020

@eddyb
Member

No idea, cc @matthewjasper @wesleywiser @spastorino (I forget who did the move to constant pointers for statics) thanks @bjorn3!

bjorn3

bjorn3 commented on Apr 2, 2020

@bjorn3
Member

I forget who did the move to constant pointers for statics

That was done in #67000.

added a commit that references this issue on Jun 1, 2020

Auto merge of rust-lang#71192 - oli-obk:eager_alloc_id_canonicalizati…

d3cba25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-thread-localsArea: Thread local storage (TLS)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @vakaras@eddyb@oli-obk@jonas-schievink@bjorn3

      Issue actions

        Make thread local accesses an `Rvalue` in MIR · Issue #70685 · rust-lang/rust