mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-12 15:30:46 +00:00
a04e9e4a0a
There is not an official documented ABI for frame pointers in Thumb2, but we should try to emit something which is useful. We use r7 as the frame pointer for Thumb code, which currently means that if a function needs to save a high register (r8-r11), it will get pushed to the stack between the frame pointer (r7) and link register (r14). This means that while a stack unwinder can follow the chain of frame pointers up the stack, it cannot know the offset to lr, so does not know which functions correspond to the stack frames. To fix this, we need to push the callee-saved registers in two batches, with the first push saving the low registers, fp and lr, and the second push saving the high registers. This is already implemented, but previously only used for iOS. This patch turns it on for all Thumb2 targets when frame pointers are required by the ABI, and the frame pointer is r7 (Windows uses r11, so this isn't a problem there). If frame pointer elimination is enabled we still emit a single push/pop even if we need a frame pointer for other reasons, to avoid increasing code size. We must also ensure that lr is pushed to the stack when using a frame pointer, so that we end up with a complete frame record. Situations that could cause this were rare, because we already push lr in most situations so that we can return using the pop instruction. Differential Revision: https://reviews.llvm.org/D23516 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279506 91177308-0d34-0410-b5e6-96231b3b80d8
87 lines
2.6 KiB
LLVM
87 lines
2.6 KiB
LLVM
; RUN: llc -filetype=asm -o - < %s -mtriple arm-arm-netbsd-eabi -disable-fp-elim| FileCheck %s --check-prefix=CHECK-ARM
|
|
; RUN: llc -filetype=asm -o - < %s -mtriple arm-arm-netbsd-eabi | FileCheck %s --check-prefix=CHECK-ARM-FP-ELIM
|
|
|
|
define void @test1() {
|
|
%tmp = alloca [ 64 x i32 ] , align 4
|
|
ret void
|
|
}
|
|
|
|
; CHECK-ARM-LABEL: test1:
|
|
; CHECK-ARM: .cfi_startproc
|
|
; CHECK-ARM: sub sp, sp, #256
|
|
; CHECK-ARM: .cfi_endproc
|
|
|
|
; CHECK-ARM-FP-ELIM-LABEL: test1:
|
|
; CHECK-ARM-FP-ELIM: .cfi_startproc
|
|
; CHECK-ARM-FP-ELIM: sub sp, sp, #256
|
|
; CHECK-ARM-FP-ELIM: .cfi_endproc
|
|
|
|
define void @test2() {
|
|
%tmp = alloca [ 4168 x i8 ] , align 4
|
|
ret void
|
|
}
|
|
|
|
; CHECK-ARM-LABEL: test2:
|
|
; CHECK-ARM: .cfi_startproc
|
|
; CHECK-ARM: push {r4, r5, r11, lr}
|
|
; CHECK-ARM: .cfi_def_cfa_offset 16
|
|
; CHECK-ARM: .cfi_offset lr, -4
|
|
; CHECK-ARM: .cfi_offset r11, -8
|
|
; CHECK-ARM: .cfi_offset r5, -12
|
|
; CHECK-ARM: .cfi_offset r4, -16
|
|
; CHECK-ARM: add r11, sp, #8
|
|
; CHECK-ARM: .cfi_def_cfa r11, 8
|
|
; CHECK-ARM: sub sp, sp, #72
|
|
; CHECK-ARM: sub sp, sp, #4096
|
|
; CHECK-ARM: .cfi_endproc
|
|
|
|
; CHECK-ARM-FP_ELIM-LABEL: test2:
|
|
; CHECK-ARM-FP_ELIM: .cfi_startproc
|
|
; CHECK-ARM-FP_ELIM: push {r4, r5}
|
|
; CHECK-ARM-FP_ELIM: .cfi_def_cfa_offset 8
|
|
; CHECK-ARM-FP_ELIM: .cfi_offset 54, -4
|
|
; CHECK-ARM-FP_ELIM: .cfi_offset r4, -8
|
|
; CHECK-ARM-FP_ELIM: sub sp, sp, #72
|
|
; CHECK-ARM-FP_ELIM: sub sp, sp, #4096
|
|
; CHECK-ARM-FP_ELIM: .cfi_def_cfa_offset 4176
|
|
; CHECK-ARM-FP_ELIM: .cfi_endproc
|
|
|
|
define i32 @test3() {
|
|
%retval = alloca i32, align 4
|
|
%tmp = alloca i32, align 4
|
|
%a = alloca [805306369 x i8], align 16
|
|
store i32 0, i32* %tmp
|
|
%tmp1 = load i32, i32* %tmp
|
|
ret i32 %tmp1
|
|
}
|
|
|
|
; CHECK-ARM-LABEL: test3:
|
|
; CHECK-ARM: .cfi_startproc
|
|
; CHECK-ARM: push {r4, r5, r11, lr}
|
|
; CHECK-ARM: .cfi_def_cfa_offset 16
|
|
; CHECK-ARM: .cfi_offset lr, -4
|
|
; CHECK-ARM: .cfi_offset r11, -8
|
|
; CHECK-ARM: .cfi_offset r5, -12
|
|
; CHECK-ARM: .cfi_offset r4, -16
|
|
; CHECK-ARM: add r11, sp, #8
|
|
; CHECK-ARM: .cfi_def_cfa r11, 8
|
|
; CHECK-ARM: sub sp, sp, #16
|
|
; CHECK-ARM: sub sp, sp, #805306368
|
|
; CHECK-ARM: bic sp, sp, #15
|
|
; CHECK-ARM: .cfi_endproc
|
|
|
|
; CHECK-ARM-FP-ELIM-LABEL: test3:
|
|
; CHECK-ARM-FP-ELIM: .cfi_startproc
|
|
; CHECK-ARM-FP-ELIM: push {r4, r5, r11}
|
|
; CHECK-ARM-FP-ELIM: .cfi_def_cfa_offset 12
|
|
; CHECK-ARM-FP-ELIM: .cfi_offset r11, -4
|
|
; CHECK-ARM-FP-ELIM: .cfi_offset r5, -8
|
|
; CHECK-ARM-FP-ELIM: .cfi_offset r4, -12
|
|
; CHECK-ARM-FP-ELIM: add r11, sp, #8
|
|
; CHECK-ARM-FP-ELIM: .cfi_def_cfa r11, 4
|
|
; CHECK-ARM-FP-ELIM: sub sp, sp, #20
|
|
; CHECK-ARM-FP-ELIM: sub sp, sp, #805306368
|
|
; CHECK-ARM-FP-ELIM: bic sp, sp, #15
|
|
; CHECK-ARM-FP-ELIM: .cfi_endproc
|
|
|