Description
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").