-
Notifications
You must be signed in to change notification settings - Fork 13.4k
atomic_load intrinsic: use const generic parameter for ordering #141507
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
base: master
Are you sure you want to change the base?
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE machinery Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
23b2539
to
4c7129b
Compare
This comment has been minimized.
This comment has been minimized.
Correct. Wasm and by extension Cranelift only have SeqCst atomics. |
let discr = ord.valtree.unwrap_branch()[0].unwrap_leaf(); | ||
let ord = discr.to_atomic_ordering(); | ||
// We have to translate from the intrinsic ordering to the backend ordering. | ||
use std::intrinsics::AtomicOrdering; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably just embed the discriminants directly in cg_ssa. The libstd cg_ssa is compiled against may use different discriminants from the one that rustc will end up compiling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed what we already do for cmp::Ordering
where we also rely on the discriminants to be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ordering
is stable with guaranteed discriminant values, AtomicOrdering
is not stable and I assume never will be, or at least not in the current location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AtomicOrdering
got specifically added for this very purpose. It's going to be exactly as stable as we need it for this purpose.
8dbc7a6
to
0cd5bdb
Compare
This comment has been minimized.
This comment has been minimized.
0cd5bdb
to
dc1bd79
Compare
This comment has been minimized.
This comment has been minimized.
dc1bd79
to
a9e3996
Compare
I think that anything the compiler lets you do with solely |
We have a gazillion intrinsics for the atomics because we encode the ordering into the intrinsic name rather than making it a parameter. This is particularly bad for those operations that take two orderings. Let's fix that!
This PR only converts
load
, to see if there's any feedback that would fundamentally change the strategy we pursue for the const generic intrinsics.The first two commits are preparation and could be a separate PR if you prefer.
@BoxyUwU -- I hope this is a use of const generics that is unlikely to explode? All we need is a const generic of enum type. We could funnel it through an integer if we had to but an enum is obviously nicer...
@bjorn3 it seems like the cranelift backend entirely ignores the ordering?