[llvm] [AArch64] Fix handling of x29/x30/x31 in inline assembly clobbers (PR #167783)
Lukáš Lalinský via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 13 03:24:20 PST 2025
================
@@ -0,0 +1,36 @@
+; RUN: llc -mtriple=aarch64 -verify-machineinstrs < %s | FileCheck %s
+
+; Test that both numeric register names (x29, x30) and their architectural
+; aliases (fp, lr) work correctly as clobbers in inline assembly.
+
+define void @clobber_x29() nounwind {
+; CHECK-LABEL: clobber_x29:
+; CHECK: str x29, [sp
+; CHECK: ldr x29, [sp
+ tail call void asm sideeffect "", "~{x29}"()
+ ret void
+}
+
+define void @clobber_fp() nounwind {
+; CHECK-LABEL: clobber_fp:
+; CHECK: str x29, [sp
+; CHECK: ldr x29, [sp
+ tail call void asm sideeffect "", "~{fp}"()
+ ret void
+}
+
+define void @clobber_x30() nounwind {
+; CHECK-LABEL: clobber_x30:
+; CHECK: str x30, [sp
+; CHECK: ldr x30, [sp
+ tail call void asm sideeffect "", "~{x30}"()
+ ret void
+}
+
+define void @clobber_lr() nounwind {
+; CHECK-LABEL: clobber_lr:
+; CHECK: str x30, [sp
+; CHECK: ldr x30, [sp
+ tail call void asm sideeffect "", "~{lr}"()
+ ret void
+}
----------------
lalinsky wrote:
Hm, I think sp should not have been added to the stringswitch, instead of:
```
warning: inline asm clobber list contains reserved registers: SP
```
it now prints:
```
error: register 'SP' allocated for constraint '{sp}' does not match required type
error: register 'SP' allocated for constraint '{x31}' does not match required type
```
Maybe I should remove it and not worry about it? It would be stupid trying to mark sp/x31 as clobbered anyway.
https://github.com/llvm/llvm-project/pull/167783
More information about the llvm-commits
mailing list