Skip to content

Commit 8d9a8e1

Browse files
committed
[ARM] r11 is reserved when using -mframe-chain=aapcs
When using the -mframe-chain=aapcs or -mframe-chain=aapcs-leaf options, we cannot use r11 as an allocatable register, even if -fomit-frame-pointer is also used. This is so that r11 will always point to a valid frame record, even if we don't create one in every function.
1 parent eacda36 commit 8d9a8e1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ getReservedRegs(const MachineFunction &MF) const {
207207
markSuperRegs(Reserved, ARM::PC);
208208
markSuperRegs(Reserved, ARM::FPSCR);
209209
markSuperRegs(Reserved, ARM::APSR_NZCV);
210-
if (TFI->hasFP(MF))
210+
if (TFI->isFPReserved(MF))
211211
markSuperRegs(Reserved, STI.getFramePointerReg());
212212
if (hasBasePointer(MF))
213213
markSuperRegs(Reserved, BasePtr);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: llc -mtriple armv7a-none-eabi < %s --frame-pointer=all | FileCheck %s --check-prefixes CHECK,FPALL-ARM
2+
; RUN: llc -mtriple armv6m-none-eabi < %s --frame-pointer=all | FileCheck %s --check-prefixes CHECK,FPALL-THUMB1
3+
; RUN: llc -mtriple armv7m-none-eabi < %s --frame-pointer=all | FileCheck %s --check-prefixes CHECK,FPALL-THUMB2
4+
; RUN: llc -mtriple armv7a-none-eabi < %s --frame-pointer=none | FileCheck %s --check-prefixes CHECK,FPNONE
5+
; RUN: llc -mtriple armv6m-none-eabi < %s --frame-pointer=none | FileCheck %s --check-prefixes CHECK,FPNONE
6+
; RUN: llc -mtriple armv7m-none-eabi < %s --frame-pointer=none | FileCheck %s --check-prefixes CHECK,FPNONE
7+
8+
; When the AAPCS frame chain is enabled, check that r11 is either used as a
9+
; frame pointer, which must point to an ABI-compatible frame record, or not
10+
; used at all, so that it continues to point to a valid frame record for the
11+
; calling function.
12+
13+
define i32 @foo(i32 %a) "target-features"="+aapcs-frame-chain" {
14+
; CHECK-LABEL: foo:
15+
; FPALL-ARM: add r11, sp,
16+
; FPALL-THUMB1: mov r11, sp
17+
; FPALL-THUMB2: add.w r11, sp,
18+
; FPNONE-NOT: r11
19+
entry:
20+
tail call void asm sideeffect "", "~{r0},~{r1},~{r2},~{r3},~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r12},~{lr}"()
21+
ret i32 %a
22+
}
23+

0 commit comments

Comments
 (0)