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

atomic RMW intrinsics: avoid unnecessary ptr/int conversions #134617

Open
RalfJung opened this issue Dec 21, 2024 · 0 comments
Open

atomic RMW intrinsics: avoid unnecessary ptr/int conversions #134617

RalfJung opened this issue Dec 21, 2024 · 0 comments
Labels
A-atomic Area: Atomics, barriers, and sync primitives A-codegen Area: Code generation A-intrinsics Area: Intrinsics A-strict-provenance Area: Strict provenance for raw pointers

Comments

@RalfJung
Copy link
Member

RalfJung commented Dec 21, 2024

Currently, the type of out atomic RMW intrinsics looks like

fn atomic_xadd_seqcst<T: Copy>(_dst: *mut T, _src: T) -> T

However, this is not quite what we want: for atomic operations on a pointer, we want dst to be something like *mut *mut T, but src should be usize. The return type should be *mut T.

This would let us avoid some unnecessary casts in AtomicPtr, and shift the burden of mapping this operation to something LLVM supports into the backend. It also makes the semantics of these operations more clear: only the provenance of the in-memory data matters; src carries no provenance.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 21, 2024
@oli-obk oli-obk changed the title atomic RMW intrinsics: avod unnecessary ptr/int conversions atomic RMW intrinsics: avoid unnecessary ptr/int conversions Dec 21, 2024
@oli-obk oli-obk added A-codegen Area: Code generation A-intrinsics Area: Intrinsics A-atomic Area: Atomics, barriers, and sync primitives A-strict-provenance Area: Strict provenance for raw pointers and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-atomic Area: Atomics, barriers, and sync primitives A-codegen Area: Code generation A-intrinsics Area: Intrinsics A-strict-provenance Area: Strict provenance for raw pointers
Projects
None yet
Development

No branches or pull requests

3 participants