Skip to content

Commit f20af73

Browse files
authored
[bolt] Support arm64 FP register spills (#73021)
At the moment llvm-bolt fails when analyzing jump tables on aarch64 in case FP register spill/reload is used.
1 parent 391a757 commit f20af73

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
314314

315315
bool isRegToRegMove(const MCInst &Inst, MCPhysReg &From,
316316
MCPhysReg &To) const override {
317+
if (Inst.getOpcode() == AArch64::FMOVDXr) {
318+
From = Inst.getOperand(1).getReg();
319+
To = Inst.getOperand(0).getReg();
320+
return true;
321+
}
322+
317323
if (Inst.getOpcode() != AArch64::ORRXrs)
318324
return false;
319325
if (Inst.getOperand(1).getReg() != AArch64::XZR)

bolt/test/AArch64/fp-reg-spill.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Check that we correctly handle arm64 fp register spills in
2+
# bolt when we are processing jump tables.
3+
# REQUIRES: system-linux
4+
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
5+
# RUN: ld.lld --emit-relocs %t.o -o %t.elf
6+
# RUN: llvm-bolt --jump-tables=move %t.elf -o %t.bolt
7+
8+
.globl _foo, _start
9+
10+
_foo:
11+
ret
12+
13+
_start:
14+
adr x6, _foo
15+
fmov d18,x6
16+
fmov x5,d18
17+
ldrb w5, [x5, w1, uxtw]
18+
add x5, x6, w5, sxtb #2
19+
br x5

0 commit comments

Comments
 (0)