-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Deprecate llvm_asm! #87590
Deprecate llvm_asm! #87590
Conversation
This comment has been minimized.
This comment has been minimized.
For simplicity's sake, is there any reason not to just use volatile operations on all platforms, and drop the complex and duplicated cfg condition? |
55e8423
to
1c95f1c
Compare
Using |
This comment has been minimized.
This comment has been minimized.
library/core/src/hint.rs
Outdated
// 1. passing the value to some external process | ||
// 2. allowing that process to access any memory that the value may point to | ||
// 3. reading a potentially modified value back | ||
#[cfg(any( |
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.
My concern with this implementation is that once support for assembly is added for any of these architectures, it is trivial to miss updating this location.
Any way we can avoid this? We could make up an intrinsic for this, perhaps?
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.
Instead of using the fallback for all other architectures, could we have an explicit list of architectures that do use the fallback?
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.
Instead of using the fallback for all other architectures, could we have an explicit list of architectures that do use the fallback?
This will likely cause problems when people try to use a new architecture with a custom json target.
Any way we can avoid this? We could make up an intrinsic for this, perhaps?
We could have a target_has_asm
cfg flag like we do for atomics. But it seems a bit excessive to have this just for black_box
.
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.
Having thought about this more, an intrinsic seems significantly more straightforward to me. But I guess I'm okay with this implementation too.
If we continue using cfgs here, consider cfg_if!
maybe? It'll reduce the clutter here significantly I feel.
I think the direction is reasonable. See the concern above, once its resolved and the tests are fixed, r=me. |
On Thu, Jul 29, 2021 at 11:19:22AM -0700, Amanieu wrote:
We could have a `target_has_asm` cfg flag like we do for atomics. But it seems a bit excessive to have this just for `black_box`.
I think it might be worthwhile regardless, and I can easily imagine
other uses of that as well.
Alternatively, is the performance improvement of using `asm!`
sufficiently large to be worth the maintenance headache? Using volatile
everywhere would leave `black_box` still entirely usable for benchmarks.
|
The main use of There are more optimizations that can be done to |
Looks good -- though Miri doesn't optimize, so skipping the function entirely like before would also work. No strong opinion either way. |
On Fri, Jul 30, 2021 at 07:33:03AM -0700, Amanieu wrote:
The main use of `black_box` is in micro-benchmarking where you want it to have as little impact as possible on the benchmark. I would argue that performance is pretty important in this case.
Then I think, for maintainability reasons, it'd be worth adding a
`cfg(target_has_asm)` or similar, even if it's internal-use-only for
now. That long architecture list seems like a painful maintenance
hazard.
|
☔ The latest upstream changes (presumably #87772) made this pull request unmergeable. Please resolve the merge conflicts. |
6eae2e0
to
53ab846
Compare
This comment has been minimized.
This comment has been minimized.
Implement `black_box` using intrinsic Introduce `black_box` intrinsic, as suggested in rust-lang#87590 (comment). This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity. cc `@Amanieu` as this is related to inline assembly cc `@bjorn3` for rustc_codegen_cranelift changes cc `@RalfJung` as this affects MIRI r? `@nagisa` I suppose
53ab846
to
4280a5e
Compare
Should be good to go, however this will conflict with #87916 due to the need for an |
Implement `black_box` using intrinsic Introduce `black_box` intrinsic, as suggested in rust-lang#87590 (comment). This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity. cc `@Amanieu` as this is related to inline assembly cc `@bjorn3` for rustc_codegen_cranelift changes cc `@RalfJung` as this affects MIRI r? `@nagisa` I suppose
Implement `black_box` using intrinsic Introduce `black_box` intrinsic, as suggested in rust-lang#87590 (comment). This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity. cc `@Amanieu` as this is related to inline assembly cc `@bjorn3` for rustc_codegen_cranelift changes cc `@RalfJung` as this affects MIRI r? `@nagisa` I suppose
☔ The latest upstream changes (presumably #87916) made this pull request unmergeable. Please resolve the merge conflicts. |
4280a5e
to
ee5adcd
Compare
@@ -7,6 +7,7 @@ | |||
// ignore-aarch64 | |||
|
|||
#![feature(llvm_asm)] | |||
#![allow(deprecated)] // llvm_asm! |
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.
Shouldn't this test be modified to use asm!
instead? This test isn't testing llvm_asm!
itself
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.
Perfectly fine to leave removal to a follow-up PR (potentially the same one that removes llvm_asm
entirely.
@bors r+ |
📌 Commit ee5adcdf9199d94aabecea7cdf8515f2877bd45e has been approved by |
☔ The latest upstream changes (presumably #87581) made this pull request unmergeable. Please resolve the merge conflicts. |
ee5adcd
to
632a400
Compare
@bors r=nagisa |
📌 Commit 632a400 has been approved by |
☀️ Test successful - checks-actions |
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in rust-lang#87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in rust-lang#91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes rust-lang#70173. Closes rust-lang#92794. Closes rust-lang#87612. Closes rust-lang#82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in rust-lang#87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in rust-lang#91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes rust-lang#70173. Closes rust-lang#92794. Closes rust-lang#87612. Closes rust-lang#82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in rust-lang#87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in rust-lang#91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes rust-lang#70173. Closes rust-lang#92794. Closes rust-lang#87612. Closes rust-lang#82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in rust-lang#87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in rust-lang#91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes rust-lang#70173. Closes rust-lang#92794. Closes rust-lang#87612. Closes rust-lang#82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
We would like to remove
llvm_asm!
from the compiler onceasm!
is stabilized. This PR deprecatesllvm_asm!
to encourage any remaining users to migrate toasm!
(or ifasm!
is not supported for their target, to add this support to rustc).The only remaining user of
llvm_asm!
in the standard library wasblack_box
, which has been rewritten to use volatile operations whenasm!
is not available on the current target.cc @rust-lang/wg-inline-asm
cc @RalfJung for the changes to
black_box
which might affect Miri.r? @nagisa