Skip to content

rustc is too strict about reserved registers on ARM #85247

Closed
@Skirmisher

Description

@Skirmisher

Recently, this commit came to my attention, as it added r9 to the list of LLVM-reserved registers on ARM according to rustc, breaking existing inline asm. I decided to look into this further, and found this page (section "Restrictions") which concisely states under what conditions certain registers are reserved in the ABI (with regards to armclang as described in the page, but it applies more generally). The relevant points are:

  • If RWPI (read-write position independent) code is enabled, R9 is reserved.
  • If needed, R7 is reserved for the frame pointer in T32 mode, and R11 is reserved in A32 mode.

However, rustc reserves these registers unconditionally. This seems incorrect, as both RWPI and frame pointers can be disabled via codegen options or a custom target. In our case, the custom target file (armv4t-none-eabi.json) has both "eliminate-frame-pointer": true and "relocation-model": "static" set, but rustc will reject uses of r9 and r11 with their respective error messages ("r9 is used internally by llvm" and "frame pointer (r11) cannot be used as an operand").

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)O-ArmTarget: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions