Skip to content

Commit 581e855

Browse files
committed
AArch64: don't claim to preserve registers used by prologue code
1 parent d9d2516 commit 581e855

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

llvm/lib/Target/AArch64/AArch64CallingConvention.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def CSR_Darwin_AArch64_TLS
468468
// CSR_Darwin_AArch64_CXX_TLS should be a subset of CSR_Darwin_AArch64_TLS.
469469
def CSR_Darwin_AArch64_CXX_TLS
470470
: CalleeSavedRegs<(add CSR_Darwin_AArch64_AAPCS,
471-
(sub (sequence "X%u", 1, 28), X15, X16, X17, X18),
471+
(sub (sequence "X%u", 1, 28), X9, X15, X16, X17, X18, X19),
472472
(sequence "D%u", 0, 31))>;
473473

474474
// CSRs that are handled by prologue, epilogue.

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ static void computeCalleeSaveRegisterPairs(
22852285
// MachO's compact unwind format relies on all registers being stored in
22862286
// pairs.
22872287
assert((!produceCompactUnwindFrame(MF) ||
2288-
CC == CallingConv::PreserveMost ||
2288+
CC == CallingConv::PreserveMost || CC == CallingConv::CXX_FAST_TLS ||
22892289
(Count & 1) == 0) &&
22902290
"Odd number of callee-saved regs to spill!");
22912291
int ByteOffset = AFI->getCalleeSavedStackSize();
@@ -2380,7 +2380,7 @@ static void computeCalleeSaveRegisterPairs(
23802380
// MachO's compact unwind format relies on all registers being stored in
23812381
// adjacent register pairs.
23822382
assert((!produceCompactUnwindFrame(MF) ||
2383-
CC == CallingConv::PreserveMost ||
2383+
CC == CallingConv::PreserveMost || CC == CallingConv::CXX_FAST_TLS ||
23842384
(RPI.isPaired() &&
23852385
((RPI.Reg1 == AArch64::LR && RPI.Reg2 == AArch64::FP) ||
23862386
RPI.Reg1 + 1 == RPI.Reg2))) &&

llvm/test/CodeGen/AArch64/cxx-tlscc.ll

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ __tls_init.exit:
9393
; CHECK-O0: stp d5, d4
9494
; CHECK-O0: stp d3, d2
9595
; CHECK-O0: stp d1, d0
96-
; CHECK-O0: stp x14, x13
97-
; CHECK-O0: stp x12, x11
98-
; CHECK-O0: stp x10, x9
96+
; CHECK-O0: str x14
97+
; CHECK-O0: stp x13, x12
98+
; CHECK-O0: stp x11, x10
9999
; CHECK-O0: stp x8, x7
100100
; CHECK-O0: stp x6, x5
101101
; CHECK-O0: stp x4, x3
@@ -110,9 +110,9 @@ __tls_init.exit:
110110
; CHECK-O0: ldp x4, x3
111111
; CHECK-O0: ldp x6, x5
112112
; CHECK-O0: ldp x8, x7
113-
; CHECK-O0: ldp x10, x9
114-
; CHECK-O0: ldp x12, x11
115-
; CHECK-O0: ldp x14, x13
113+
; CHECK-O0: ldp x11, x10
114+
; CHECK-O0: ldp x13, x12
115+
; CHECK-O0: ldr x14
116116
; CHECK-O0: ldp d1, d0
117117
; CHECK-O0: ldp d3, d2
118118
; CHECK-O0: ldp d5, d4
@@ -220,5 +220,31 @@ entry:
220220
ret void
221221
}
222222

223+
define cxx_fast_tlscc void @weird_prologue_regs(i32 %n) #1 {
224+
; CHECK-LABEL: weird_prologue_regs:
225+
; CHECK-NOT: str x9
226+
; CHECK-NOT: stp{{.*}}x9{{.*}}[
227+
; CHECK-NOT: str x19
228+
; CHECK-NOT: stp{{.*}}x19{{.*}}[
229+
230+
; CHECK: sub x9, sp, #
231+
; CHECK: and sp, x9, #0x
232+
; CHECK: mov x19, sp
233+
234+
; CHECK-NOT: str x9
235+
; CHECK-NOT: stp{{.*}}x9{{.*}}[
236+
; CHECK-NOT: str x19
237+
; CHECK-NOT: stp{{.*}}x19{{.*}}[
238+
239+
%p0 = alloca i32, i32 200
240+
%p1 = alloca i32, align 32
241+
%p2 = alloca i32, i32 %n
242+
call void @callee(i32* %p0)
243+
call void @callee(i32* %p1)
244+
call void @callee(i32* %p2)
245+
ret void
246+
}
247+
declare void @callee(i32*)
248+
223249
attributes #0 = { nounwind "frame-pointer"="all" }
224250
attributes #1 = { nounwind }

0 commit comments

Comments
 (0)