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

inline assembly register limits aren't correct when using instruction_set attribute #92378

Closed
Lokathor opened this issue Dec 28, 2021 · 1 comment · Fixed by #94169
Closed
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Lokathor
Copy link
Contributor

First discussed on zulip.

Quick summary: the set of what registers are available for inline assembly is related to the current target arch. However, the instruction_set attribute lets a function be compiled for what's effectively an alternate arch. This should allow the other arch's registers to be used, but currently that's not the case.

  • Specifically for ARM a32/t32, the thumb-mode target attribute is either not present (a32) or present (t32) in the target, and using the instruction_set attribute lets you have the opposite mode.
  • Note: The actual assembly code is already compiled correctly on LLVM's side, it's just that rustc gives you the incorrect register class limits.

Quoting Amanieu's Zulip post on the probable fix for this:

You'd need to somehow remove the thumb-mode target feature from the list passed to the asm handling code in ast_lowering and intrinsicck when the containing function uses the a32 ISA.

@Lokathor Lokathor added the C-bug Category: This is a bug. label Dec 28, 2021
@BGR360
Copy link
Contributor

BGR360 commented Dec 29, 2021

@rustbot label +A-inline-assembly +F-asm +T-compiler

@rustbot rustbot added A-inline-assembly Area: inline asm!(..) F-asm `#![feature(asm)]` (not `llvm_asm`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 29, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 20, 2022
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes rust-lang#92378
Fixes rust-lang#85247

r? `@nagisa`
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 20, 2022
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes rust-lang#92378
Fixes rust-lang#85247

r? ``@nagisa``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2022
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes rust-lang#92378
Fixes rust-lang#85247

r? `@nagisa`
@bors bors closed this as completed in 1cf2e69 Feb 22, 2022
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Feb 23, 2022
Fix several asm! related issues

This is a combination of several fixes, each split into a separate commit. Splitting these into PRs is not practical since they conflict with each other.

Fixes rust-lang#92378
Fixes rust-lang#85247

r? ``@nagisa``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: inline asm!(..) C-bug Category: This is a bug. F-asm `#![feature(asm)]` (not `llvm_asm`) 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.

3 participants