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

Unable to mark ARM32's r14 register as clobbered in asm! #82052

Closed
jrvanwhy opened this issue Feb 13, 2021 · 3 comments · Fixed by #82141
Closed

Unable to mark ARM32's r14 register as clobbered in asm! #82052

jrvanwhy opened this issue Feb 13, 2021 · 3 comments · Fixed by #82141
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. F-asm `#![feature(asm)]` (not `llvm_asm`) O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jrvanwhy
Copy link
Contributor

I attempted to compile a crate containing the following expression:

unsafe { asm!("svc 0", lateout("r14") _); }

I expected it to compile successfully.

Instead, I received this error:

error: couldn't allocate output register for constraint '{r14}'

rustc --version --verbose:

rustc 1.52.0-nightly (3f5aee2d5 2021-02-12)
binary: rustc
commit-hash: 3f5aee2d5241139d808f4fdece0026603489afd1
commit-date: 2021-02-12
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

RUST_BACKTRACE=1 omitted, it did not produce anything else.

@Amanieu diagnosed the cause and offered a solution here.

@jrvanwhy jrvanwhy added the C-bug Category: This is a bug. label Feb 13, 2021
@jrvanwhy
Copy link
Contributor Author

While I try to spin up a rustc development environment, can someone point me to the tests for this code? I don't see any tests in the crate.

} else if reg == InlineAsmReg::AArch64(AArch64InlineAsmReg::x30) {
// LLVM doesn't recognize x30
"{lr}".to_string()
} else {

@Amanieu
Copy link
Member

Amanieu commented Feb 13, 2021

// Regression test for #75761
// CHECK-LABEL: issue_75761:
// CHECK: str {{.*}}x30
// CHECK: //APP
// CHECK: //NO_APP
// CHECK: ldr {{.*}}x30
#[no_mangle]
pub unsafe fn issue_75761() {
asm!("", out("v0") _, out("x30") _);
}

@jonas-schievink jonas-schievink added A-inline-assembly Area: Inline assembly (`asm!(…)`) F-asm `#![feature(asm)]` (not `llvm_asm`) O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 13, 2021
@Amanieu Amanieu added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Feb 14, 2021
@jrvanwhy
Copy link
Contributor Author

I think I have a working rustc development environment now. I'll try to fix this -- thank you @Amanieu for making this easy for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. F-asm `#![feature(asm)]` (not `llvm_asm`) O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state 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