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

"asm_sub_register" could provide a bit more helpful information #121593

Closed
RalfJung opened this issue Feb 25, 2024 · 1 comment · Fixed by #121940
Closed

"asm_sub_register" could provide a bit more helpful information #121593

RalfJung opened this issue Feb 25, 2024 · 1 comment · Fixed by #121940
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

RalfJung commented Feb 25, 2024

Code

pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) {
    std::arch::asm!(
        "movnti [{mem_addr}], {a}",
        mem_addr = in(reg) mem_addr,
        a = in(reg) a,
    );
}

Current output

warning: formatting may not be suitable for sub-register argument
 --> src/lib.rs:3:31
  |
3 |         "movnti [{mem_addr}], {a}",
  |                               ^^^
4 |         mem_addr = in(reg) mem_addr,
5 |         a = in(reg) a,
  |                     - for this argument
  |
  = help: use `{1:e}` to have the register formatted as `eax`
  = help: or use `{1:r}` to keep the default formatting of `rax`
  = note: `#[warn(asm_sub_register)]` on by default

Desired output

warning: formatting may not be suitable for sub-register argument
 --> src/lib.rs:3:31
  |
3 |         "movnti [{mem_addr}], {a}",
  |                               ^^^
4 |         mem_addr = in(reg) mem_addr,
5 |         a = in(reg) a,
  |                     - for this argument
  |
  = help: use `{1:e}` to have the register formatted as `eax` (for 32bit values)
  = help: or use `{1:r}` to keep the default formatting of `rax` (for 64bit values)
  = note: `#[warn(asm_sub_register)]` on by default

Rationale and extra context

This is my first time writing inline assembly. I don't yet know all the Intel register class prefixes by hand. So telling me which prefix corresponds to which size would be very helpful. :)

Other cases

No response

Rust Version

$ rustc --version -v
rustc 1.78.0-nightly (8f359beca 2024-02-23)
binary: rustc
commit-hash: 8f359beca4e58bc3ae795a666301a8f47023044c
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Anything else?

No response

@RalfJung RalfJung added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 25, 2024
@veera-sivarajan
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 14, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 23, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 24, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 24, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2024
Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 24, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 24, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
@bors bors closed this as completed in 9aac0c9 Mar 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 24, 2024
Rollup merge of rust-lang#121940 - veera-sivarajan:bugfix-121593, r=fmease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
RenjiSann pushed a commit to RenjiSann/rust that referenced this issue Mar 25, 2024
…mease

Mention Register Size in `#[warn(asm_sub_register)]`

Fixes rust-lang#121593

Displays the register size information obtained from `suggest_modifier()` and `default_modifier()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants