Repository navigation
Support NonNull pointers as asm! input operands - #165008
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
efa94c9 to
61b2e57
Compare
|
re: that Zulip discussion, Amanieu was critical of this idea in its unqualified form and as our de facto expert in inline r? @Amanieu |
|
LGTM, but this needs a positive codegen test. The current tests all fail and never reach codegen. |
61b2e57 to
8250453
Compare
|
Added codegen tests to all the |
This comment has been minimized.
This comment has been minimized.
8250453 to
fd4fdd7
Compare
|
This will need a PR to update the reference re: input types, especially if we have no feature gate for this and it is instantly stable. |
|
that or it needs to be an unstable feature. I don't particularly know what is preferred here on that front. Seems trivial to me. |
Shared and mutable references as `asm!` input operands were introduced at least before 8ab0f2d3c5a85563b98c4896116e3d53154fff9c; `MaybeUninit` was introduced in rust-lang/rust#114790; `NonNull` is awaiting stabilization in rust-lang/rust#165008.
Shared and mutable references as `asm!` input operands were introduced at least before 8ab0f2d3c5a85563b98c4896116e3d53154fff9c; `MaybeUninit` was introduced in rust-lang/rust#114790; `NonNull` is awaiting stabilization in rust-lang/rust#165008.
Shared and mutable references as `asm!` input operands were introduced at least before 8ab0f2d3c5a85563b98c4896116e3d53154fff9c; `MaybeUninit` was introduced in rust-lang/rust#114790; `NonNull` is awaiting stabilization in rust-lang/rust#165008.
Shared and mutable references as `asm!` input operands were introduced at least before 8ab0f2d3c5a85563b98c4896116e3d53154fff9c; `MaybeUninit` was introduced in rust-lang/rust#114790; `NonNull` is awaiting stabilization in rust-lang/rust#165008.
|
Nominating for lang since this is a new capability for inline asm. |
|
@hsanzg Could you add an unstable feature gate for this so this isn't instantly stable? In general we are adverse to instantly stabilizing new features unless we really have to. |
Shared and mutable references as `asm!` input operands were introduced at least before 8ab0f2d3c5a85563b98c4896116e3d53154fff9c; `MaybeUninit` was introduced in rust-lang/rust#114790; `NonNull` is awaiting stabilization in rust-lang/rust#165008.
fd4fdd7 to
7ade73b
Compare
|
@bors r+ |
Support `NonNull` pointers as `asm!` input operands Tracking issue: rust-lang#166132 Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` _outputs_ is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved. Support for `Box<T>` and `Optional<NonNull<T>>` seems a bit more debatable, so that's left as future work (which might require more than a FCP).
…uwer Rollup of 14 pull requests Successful merges: - #166266 (miri subtree update) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #165618 (Implement RangeIntersect on core::range types) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166142 (Lower to `hir::Param`s for extern functions) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166269 (libcore: Revert some comment changes) - #166287 (Use `core::ptr` in `implicit_provenance_casts` help for `no_std` crates) - #166306 (bootstrap: Stop passing `-Ztrim-paths` to cargo now that it's stable in beta)
@bors try jobs=test-x86_64-rust-for-linux |
This comment has been minimized.
This comment has been minimized.
Support `NonNull` pointers as `asm!` input operands try-job: test-x86_64-rust-for-linux
Support `NonNull` pointers as `asm!` input operands Tracking issue: rust-lang#166132 Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` _outputs_ is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved. Support for `Box<T>` and `Optional<NonNull<T>>` seems a bit more debatable, so that's left as future work (which might require more than a FCP).
Rollup of 15 pull requests Successful merges: - #166266 (miri subtree update) - #165720 (windows: remove redundant prefix parsing in `PathBuf::_push`) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
Support `NonNull` pointers as `asm!` input operands Tracking issue: rust-lang#166132 Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` _outputs_ is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved. Support for `Box<T>` and `Optional<NonNull<T>>` seems a bit more debatable, so that's left as future work (which might require more than a FCP).
Support `NonNull` pointers as `asm!` input operands Tracking issue: rust-lang#166132 Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` _outputs_ is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved. Support for `Box<T>` and `Optional<NonNull<T>>` seems a bit more debatable, so that's left as future work (which might require more than a FCP).
…uwer Rollup of 19 pull requests Successful merges: - #166266 (miri subtree update) - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
…uwer Rollup of 18 pull requests Successful merges: - #164878 (Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(packed)]`) - #165008 (Support `NonNull` pointers as `asm!` input operands) - #165892 (`rustc_builtin_macros` cleanup, part 10) - #165930 (Add red-green mark when dumping dep graph. Show DefIds if available) - #166280 (std: also mark doctests with skip_unsupported_miri_tests) - #166295 (use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of `cfg!(debug_assertions)`) - #164485 (Stabilize unchecked `nonzero_ops`) - #165618 (Implement RangeIntersect on core::range types) - #165782 (Make unsafe unknown diagnostic attributes an error again) - #165833 (Deallocate with the right provenance on Windows) - #165834 (Implement tidy alphabetical --bless on Windows) - #165889 (Fix docs of alloc fn: Allocator API stabilized) - #165923 (Don't load/store a LLVM aggregate type when returning an array from a generic SIMD intrinsic) - #166012 (Added more queries to AdtDef in rustc_public to check for rust language types) - #166186 (OpenOptions::append: clarify docs) - #166216 (Stop using #![no_core] in profiler_builtins) - #166259 (fmt: Improve `Debug` for `FormattingOptions`) - #166263 (Show slice split results for empty and singleton slices)
Rollup merge of #165008 - hsanzg:rich-asm-ptr-inputs, r=Amanieu Support `NonNull` pointers as `asm!` input operands Tracking issue: #166132 Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` _outputs_ is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved. Support for `Box<T>` and `Optional<NonNull<T>>` seems a bit more debatable, so that's left as future work (which might require more than a FCP).
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (4963997): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Artifact size: 405.67 MiB -> 405.76 MiB (0.02%) |
|
perf triage: The regressions are in tiny @rustbot label: +perf-regression-triaged |
View all comments
Tracking issue: #166132
Currently the
asm!macro supports raw (thin) pointers as operands, and references as input operands. As discussed in Zulip, it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin)NonNullpointer inputs. The reason for not allowingNonNulloutputs is that theasm!code has no way to explicitly assert that the safety invariant ofNonNullis preserved.Support for
Box<T>andOptional<NonNull<T>>seems a bit more debatable, so that's left as future work (which might require more than a FCP).I'll make the existing error messages dependent on whether the operand is allowed specifically as an input in a subsequent PR (because it also affects references). Right now the message is a bit too general.