Commit 448a86d
committed
[AArch64] Fix handling of x29/x30 in inline assembly clobbers
The AArch64 backend was silently ignoring inline assembly clobbers when numeric register names (x29, x30) were used instead of their architectural aliases (fp, lr). I found this bug via inline assembly in Zig, which not normalize the register names the way clang does. There is an incoplete workaround for this in Rust, but that only handles `x30/lr`, not `x29/fp`. I thought it would make sense to fix this properly rather than adding a workaround to Zig. This patch adds explicit handling in getRegForInlineAsmConstraint() to map both numeric and alias forms to the correct physical registers, following the same pattern used by the RISC-V backend. I've left `x31/sp` without changes, it would nice to have to have warning when trying to clobber `x31`, just like there is for `sp`, but that register needs different handling, so it's best done separately. If you have code like this: define void @clobber_x30() nounwind { tail call void asm sideeffect "nop", "~{x30}"() ret void } Here is the generated assembly before: clobber_x30: // @clobber_x30 //APP nop //NO_APP ret And after: clobber_x30: // @clobber_x30 str x30, [sp, #-16]! // 8-byte Folded Spill //APP nop //NO_APP ldr x30, [sp], #16 // 8-byte Folded Reload ret1 parent cf9cb54 commit 448a86d
File tree
2 files changed
+51
-0
lines changed- llvm
- lib/Target/AArch64
- test/CodeGen/AArch64
2 files changed
+51
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
13126 | 13127 | | |
13127 | 13128 | | |
13128 | 13129 | | |
| 13130 | + | |
| 13131 | + | |
| 13132 | + | |
| 13133 | + | |
| 13134 | + | |
| 13135 | + | |
| 13136 | + | |
| 13137 | + | |
| 13138 | + | |
| 13139 | + | |
| 13140 | + | |
| 13141 | + | |
| 13142 | + | |
| 13143 | + | |
13129 | 13144 | | |
13130 | 13145 | | |
13131 | 13146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments