Skip to content

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

Closed

Description

@jrvanwhy

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.

Activity

  1. jrvanwhy commented on Feb 13, 2021

    @jrvanwhy
    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 {

  2. Amanieu commented on Feb 13, 2021

    @Amanieu
    Member

    // 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") _);
    }

  3. added
    A-inline-assemblyArea: Inline assembly (`asm!(…)`)
    F-asm`#![feature(asm)]` (not `llvm_asm`)
    O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 13, 2021
  4. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    on Feb 14, 2021
  5. jrvanwhy commented on Feb 15, 2021

    @jrvanwhy
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.F-asm`#![feature(asm)]` (not `llvm_asm`)O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 stateT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions