-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Simplify memory ordering intrinsics #97423
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
|
1ae453e
to
123c92a
Compare
cc @tmiasko |
This updates the stdarch submodule to include rust-lang/stdarch@dc4b2e2, which isn't merged in stdarch's main branch yet, since that change needs to happen at the same time as the rest of this PR. |
This comment has been minimized.
This comment has been minimized.
Looks good to me. Thanks! r=me with commits squashed. |
This comment has been minimized.
This comment has been minimized.
7d48e22
to
512099e
Compare
cc @Amanieu for |
512099e
to
126a41f
Compare
Since the |
126a41f
to
2d02416
Compare
Oops, got distracted. I've updated the PR following your suggestion. :) |
@bors r+ |
📌 Commit 2d02416 has been approved by |
… r=tmiasko Simplify memory ordering intrinsics This changes the names of the atomic intrinsics to always fully include their memory ordering arguments. ```diff - atomic_cxchg + atomic_cxchg_seqcst_seqcst - atomic_cxchg_acqrel + atomic_cxchg_acqrel_release - atomic_cxchg_acqrel_failrelaxed + atomic_cxchg_acqrel_relaxed // And so on. ``` - `seqcst` is no longer implied - The failure ordering on chxchg is no longer implied in some cases, but now always explicitly part of the name. - `release` is no longer shortened to just `rel`. That was especially confusing, since `relaxed` also starts with `rel`. - `acquire` is no longer shortened to just `acq`, such that the names now all match the `std::sync::atomic::Ordering` variants exactly. - This now allows for more combinations on the compare exchange operations, such as `atomic_cxchg_acquire_release`, which is necessary for rust-lang#68464. - This PR only exposes the new possibilities through unstable intrinsics, but not yet through the stable API. That's for [a separate PR](rust-lang#98383) that requires an FCP. Suffixes for operations with a single memory order: | Order | Before | After | |---------|--------------|------------| | Relaxed | `_relaxed` | `_relaxed` | | Acquire | `_acq` | `_acquire` | | Release | `_rel` | `_release` | | AcqRel | `_acqrel` | `_acqrel` | | SeqCst | (none) | `_seqcst` | Suffixes for compare-and-exchange operations with two memory orderings: | Success | Failure | Before | After | |---------|---------|--------------------------|--------------------| | Relaxed | Relaxed | `_relaxed` | `_relaxed_relaxed` | | Relaxed | Acquire | ❌ | `_relaxed_acquire` | | Relaxed | SeqCst | ❌ | `_relaxed_seqcst` | | Acquire | Relaxed | `_acq_failrelaxed` | `_acquire_relaxed` | | Acquire | Acquire | `_acq` | `_acquire_acquire` | | Acquire | SeqCst | ❌ | `_acquire_seqcst` | | Release | Relaxed | `_rel` | `_release_relaxed` | | Release | Acquire | ❌ | `_release_acquire` | | Release | SeqCst | ❌ | `_release_seqcst` | | AcqRel | Relaxed | `_acqrel_failrelaxed` | `_acqrel_relaxed` | | AcqRel | Acquire | `_acqrel` | `_acqrel_acquire` | | AcqRel | SeqCst | ❌ | `_acqrel_seqcst` | | SeqCst | Relaxed | `_failrelaxed` | `_seqcst_relaxed` | | SeqCst | Acquire | `_failacq` | `_seqcst_acquire` | | SeqCst | SeqCst | (none) | `_seqcst_seqcst` |
… r=tmiasko Simplify memory ordering intrinsics This changes the names of the atomic intrinsics to always fully include their memory ordering arguments. ```diff - atomic_cxchg + atomic_cxchg_seqcst_seqcst - atomic_cxchg_acqrel + atomic_cxchg_acqrel_release - atomic_cxchg_acqrel_failrelaxed + atomic_cxchg_acqrel_relaxed // And so on. ``` - `seqcst` is no longer implied - The failure ordering on chxchg is no longer implied in some cases, but now always explicitly part of the name. - `release` is no longer shortened to just `rel`. That was especially confusing, since `relaxed` also starts with `rel`. - `acquire` is no longer shortened to just `acq`, such that the names now all match the `std::sync::atomic::Ordering` variants exactly. - This now allows for more combinations on the compare exchange operations, such as `atomic_cxchg_acquire_release`, which is necessary for rust-lang#68464. - This PR only exposes the new possibilities through unstable intrinsics, but not yet through the stable API. That's for [a separate PR](rust-lang#98383) that requires an FCP. Suffixes for operations with a single memory order: | Order | Before | After | |---------|--------------|------------| | Relaxed | `_relaxed` | `_relaxed` | | Acquire | `_acq` | `_acquire` | | Release | `_rel` | `_release` | | AcqRel | `_acqrel` | `_acqrel` | | SeqCst | (none) | `_seqcst` | Suffixes for compare-and-exchange operations with two memory orderings: | Success | Failure | Before | After | |---------|---------|--------------------------|--------------------| | Relaxed | Relaxed | `_relaxed` | `_relaxed_relaxed` | | Relaxed | Acquire | ❌ | `_relaxed_acquire` | | Relaxed | SeqCst | ❌ | `_relaxed_seqcst` | | Acquire | Relaxed | `_acq_failrelaxed` | `_acquire_relaxed` | | Acquire | Acquire | `_acq` | `_acquire_acquire` | | Acquire | SeqCst | ❌ | `_acquire_seqcst` | | Release | Relaxed | `_rel` | `_release_relaxed` | | Release | Acquire | ❌ | `_release_acquire` | | Release | SeqCst | ❌ | `_release_seqcst` | | AcqRel | Relaxed | `_acqrel_failrelaxed` | `_acqrel_relaxed` | | AcqRel | Acquire | `_acqrel` | `_acqrel_acquire` | | AcqRel | SeqCst | ❌ | `_acqrel_seqcst` | | SeqCst | Relaxed | `_failrelaxed` | `_seqcst_relaxed` | | SeqCst | Acquire | `_failacq` | `_seqcst_acquire` | | SeqCst | SeqCst | (none) | `_seqcst_seqcst` |
510af15
to
4982a59
Compare
@bors r=tmiasko |
📌 Commit 4982a59 has been approved by |
… r=tmiasko Simplify memory ordering intrinsics This changes the names of the atomic intrinsics to always fully include their memory ordering arguments. ```diff - atomic_cxchg + atomic_cxchg_seqcst_seqcst - atomic_cxchg_acqrel + atomic_cxchg_acqrel_release - atomic_cxchg_acqrel_failrelaxed + atomic_cxchg_acqrel_relaxed // And so on. ``` - `seqcst` is no longer implied - The failure ordering on chxchg is no longer implied in some cases, but now always explicitly part of the name. - `release` is no longer shortened to just `rel`. That was especially confusing, since `relaxed` also starts with `rel`. - `acquire` is no longer shortened to just `acq`, such that the names now all match the `std::sync::atomic::Ordering` variants exactly. - This now allows for more combinations on the compare exchange operations, such as `atomic_cxchg_acquire_release`, which is necessary for rust-lang#68464. - This PR only exposes the new possibilities through unstable intrinsics, but not yet through the stable API. That's for [a separate PR](rust-lang#98383) that requires an FCP. Suffixes for operations with a single memory order: | Order | Before | After | |---------|--------------|------------| | Relaxed | `_relaxed` | `_relaxed` | | Acquire | `_acq` | `_acquire` | | Release | `_rel` | `_release` | | AcqRel | `_acqrel` | `_acqrel` | | SeqCst | (none) | `_seqcst` | Suffixes for compare-and-exchange operations with two memory orderings: | Success | Failure | Before | After | |---------|---------|--------------------------|--------------------| | Relaxed | Relaxed | `_relaxed` | `_relaxed_relaxed` | | Relaxed | Acquire | ❌ | `_relaxed_acquire` | | Relaxed | SeqCst | ❌ | `_relaxed_seqcst` | | Acquire | Relaxed | `_acq_failrelaxed` | `_acquire_relaxed` | | Acquire | Acquire | `_acq` | `_acquire_acquire` | | Acquire | SeqCst | ❌ | `_acquire_seqcst` | | Release | Relaxed | `_rel` | `_release_relaxed` | | Release | Acquire | ❌ | `_release_acquire` | | Release | SeqCst | ❌ | `_release_seqcst` | | AcqRel | Relaxed | `_acqrel_failrelaxed` | `_acqrel_relaxed` | | AcqRel | Acquire | `_acqrel` | `_acqrel_acquire` | | AcqRel | SeqCst | ❌ | `_acqrel_seqcst` | | SeqCst | Relaxed | `_failrelaxed` | `_seqcst_relaxed` | | SeqCst | Acquire | `_failacq` | `_seqcst_acquire` | | SeqCst | SeqCst | (none) | `_seqcst_seqcst` |
Rollup of 7 pull requests Successful merges: - rust-lang#97423 (Simplify memory ordering intrinsics) - rust-lang#97542 (Use typed indices in argument mismatch algorithm) - rust-lang#97786 (Account for `-Z simulate-remapped-rust-src-base` when resolving remapped paths) - rust-lang#98277 (Fix trait object reborrow suggestion) - rust-lang#98525 (Add regression test for rust-lang#79224) - rust-lang#98549 (interpret: do not prune requires_caller_location stack frames quite so early) - rust-lang#98603 (Some borrowck diagnostic fixes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The updates required were related to the following changes: - Simplify memory ordering intrinsics - rust-lang/rust#97423 - once cell renamings - rust-lang/rust#98165 - Rename the ConstS::val field as kind - rust-lang/rust#97935 - Remove the source archive functionality of ArchiveWriter - rust-lang/rust#98098 - Use valtrees as the type-system representation for constant values - rust-lang/rust#96591
* Update toolchain to 2022-07-05 The updates required were related to the following changes: - Simplify memory ordering intrinsics - rust-lang/rust#97423 - once cell renamings - rust-lang/rust#98165 - Rename the ConstS::val field as kind - rust-lang/rust#97935 - Remove the source archive functionality of ArchiveWriter - rust-lang/rust#98098 - Use valtrees as the type-system representation for constant values - rust-lang/rust#96591 * Codegen unimplemented for unsupported constant slices See #1339 for more details. * Fix copyright check * Use codegen_option_span instead
* Add a test for atomic operations introduced in rust-lang#97423 & rust-lang#98383. * Add a test for fallback code generation strategy used on LLVM 12 introduced in rust-lang#98385. Use a separate test case instead of a revision system since test will be gone once LLVM 12 is no longer supported.
Test codegen of atomic compare-exchange with additional memory orderings * Add a test for atomic operations introduced in rust-lang#97423 & rust-lang#98383. * Add a test for fallback code generation strategy used on LLVM 12 introduced in rust-lang#98385. Use a separate test case instead of a revision system since test will be gone once LLVM 12 is no longer supported.
It seems that the error messages for these updated intrinsics are out-of-date with the new names, as they say error[E0425]: cannot find function `atomic_xchg_acq` in module `core::intrinsics`
--> src/atomics.rs:167:33
|
167 | ) = ::core::intrinsics::atomic_xchg_acq(&mut x, 33 as libc::c_int);
| ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `atomic_cxchg_acq`
|
::: /home/kkysen/.rustup/toolchains/nightly-2022-08-08-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:320:5
|
320 | pub fn atomic_cxchg_acquire_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
| -------------------------------------------------------------------------------------- similarly named function `atomic_cxchg_acq` defined here
error[E0425]: cannot find function `atomic_store_rel` in module `core::intrinsics`
--> src/atomics.rs:171:25
|
171 | ::core::intrinsics::atomic_store_rel(&mut x, 0);
| ^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
|
::: /home/kkysen/.rustup/toolchains/nightly-2022-08-08-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
|
523 | pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
| -------------------------------------------------------- similarly named function `atomic_store` defined here |
This changes the names of the atomic intrinsics to always fully include their memory ordering arguments.
seqcst
is no longer impliedrelease
is no longer shortened to justrel
. That was especially confusing, sincerelaxed
also starts withrel
.acquire
is no longer shortened to justacq
, such that the names now all match thestd::sync::atomic::Ordering
variants exactly.atomic_cxchg_acquire_release
, which is necessary for Lift unnecessary restriction on CAS failure ordering #68464.Suffixes for operations with a single memory order:
_relaxed
_relaxed
_acq
_acquire
_rel
_release
_acqrel
_acqrel
_seqcst
Suffixes for compare-and-exchange operations with two memory orderings:
_relaxed
_relaxed_relaxed
_relaxed_acquire
_relaxed_seqcst
_acq_failrelaxed
_acquire_relaxed
_acq
_acquire_acquire
_acquire_seqcst
_rel
_release_relaxed
_release_acquire
_release_seqcst
_acqrel_failrelaxed
_acqrel_relaxed
_acqrel
_acqrel_acquire
_acqrel_seqcst
_failrelaxed
_seqcst_relaxed
_failacq
_seqcst_acquire
_seqcst_seqcst