Commit 82eb730
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 4881512 commit 82eb730
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 | | |
| |||
13157 | 13158 | | |
13158 | 13159 | | |
13159 | 13160 | | |
| 13161 | + | |
| 13162 | + | |
| 13163 | + | |
| 13164 | + | |
| 13165 | + | |
| 13166 | + | |
| 13167 | + | |
| 13168 | + | |
| 13169 | + | |
| 13170 | + | |
| 13171 | + | |
| 13172 | + | |
| 13173 | + | |
| 13174 | + | |
13160 | 13175 | | |
13161 | 13176 | | |
13162 | 13177 | | |
| |||
| 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