2012-01-07 06:19:37 +08:00
|
|
|
; RUN: llc < %s -mcpu=cortex-a8 -align-neon-spills=0 | FileCheck %s
|
|
|
|
; RUN: llc < %s -mcpu=cortex-a8 -align-neon-spills=1 | FileCheck %s --check-prefix=NEON
|
2011-12-21 06:15:04 +08:00
|
|
|
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
|
|
|
|
target triple = "thumbv7-apple-ios"
|
|
|
|
|
|
|
|
; CHECK: f
|
|
|
|
; This function is forced to spill a double.
|
|
|
|
; Verify that the spill slot is properly aligned.
|
|
|
|
;
|
|
|
|
; The caller-saved r4 is used as a scratch register for stack realignment.
|
|
|
|
; CHECK: push {r4, r7, lr}
|
2015-01-08 23:09:14 +08:00
|
|
|
; CHECK: bfc r4, #0, #3
|
2011-12-21 06:15:04 +08:00
|
|
|
; CHECK: mov sp, r4
|
[ARM] Generate consistent frame records for Thumb2
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
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @f(double* nocapture %p) nounwind ssp "no-frame-pointer-elim"="true" {
|
2011-12-21 06:15:04 +08:00
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load double, double* %p, align 4
|
2011-12-21 06:15:04 +08:00
|
|
|
tail call void asm sideeffect "", "~{d8},~{d9},~{d10},~{d11},~{d12},~{d13},~{d14},~{d15}"() nounwind
|
|
|
|
tail call void @g() nounwind
|
|
|
|
store double %0, double* %p, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2011-12-23 08:36:18 +08:00
|
|
|
; NEON: f
|
|
|
|
; NEON: push {r4, r7, lr}
|
|
|
|
; NEON: sub.w r4, sp, #64
|
2015-01-08 23:09:14 +08:00
|
|
|
; NEON: bfc r4, #0, #4
|
2011-12-23 08:36:18 +08:00
|
|
|
; Stack pointer must be updated before the spills.
|
|
|
|
; NEON: mov sp, r4
|
2013-02-22 18:01:33 +08:00
|
|
|
; NEON: vst1.64 {d8, d9, d10, d11}, [r4:128]!
|
|
|
|
; NEON: vst1.64 {d12, d13, d14, d15}, [r4:128]
|
2011-12-23 08:36:18 +08:00
|
|
|
; Stack pointer adjustment for the stack frame contents.
|
|
|
|
; This could legally happen before the spills.
|
|
|
|
; Since the spill slot is only 8 bytes, technically it would be fine to only
|
|
|
|
; subtract #8 here. That would leave sp less aligned than some stack slots,
|
|
|
|
; and would probably blow MFI's mind.
|
|
|
|
; NEON: sub sp, #16
|
|
|
|
; The epilog is free to use another scratch register than r4.
|
|
|
|
; NEON: add r[[R4:[0-9]+]], sp, #16
|
2013-02-22 18:01:33 +08:00
|
|
|
; NEON: vld1.64 {d8, d9, d10, d11}, [r[[R4]]:128]!
|
|
|
|
; NEON: vld1.64 {d12, d13, d14, d15}, [r[[R4]]:128]
|
2011-12-23 08:36:18 +08:00
|
|
|
; The stack pointer restore must happen after the reloads.
|
|
|
|
; NEON: mov sp,
|
|
|
|
; NEON: pop
|
|
|
|
|
2011-12-21 06:15:04 +08:00
|
|
|
declare void @g()
|
2011-12-23 08:36:18 +08:00
|
|
|
|
|
|
|
; Spill 7 d-registers.
|
[ARM] Generate consistent frame records for Thumb2
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
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @f7(double* nocapture %p) nounwind ssp "no-frame-pointer-elim"="true" {
|
2011-12-23 08:36:18 +08:00
|
|
|
entry:
|
|
|
|
tail call void asm sideeffect "", "~{d8},~{d9},~{d10},~{d11},~{d12},~{d13},~{d14}"() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; NEON: f7
|
|
|
|
; NEON: push {r4, r7, lr}
|
|
|
|
; NEON: sub.w r4, sp, #56
|
2015-01-08 23:09:14 +08:00
|
|
|
; NEON: bfc r4, #0, #4
|
2011-12-23 08:36:18 +08:00
|
|
|
; Stack pointer must be updated before the spills.
|
|
|
|
; NEON: mov sp, r4
|
2013-02-22 18:01:33 +08:00
|
|
|
; NEON: vst1.64 {d8, d9, d10, d11}, [r4:128]!
|
|
|
|
; NEON: vst1.64 {d12, d13}, [r4:128]
|
2011-12-23 08:36:18 +08:00
|
|
|
; NEON: vstr d14, [r4, #16]
|
|
|
|
; Epilog
|
|
|
|
; NEON: vld1.64 {d8, d9, d10, d11},
|
|
|
|
; NEON: vld1.64 {d12, d13},
|
|
|
|
; NEON: vldr d14,
|
|
|
|
; The stack pointer restore must happen after the reloads.
|
|
|
|
; NEON: mov sp,
|
|
|
|
; NEON: pop
|
|
|
|
|
|
|
|
; Spill 7 d-registers, leave a hole.
|
[ARM] Generate consistent frame records for Thumb2
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
llvm-svn: 279506
2016-08-23 17:19:22 +08:00
|
|
|
define void @f3plus4(double* nocapture %p) nounwind ssp "no-frame-pointer-elim"="true" {
|
2011-12-23 08:36:18 +08:00
|
|
|
entry:
|
|
|
|
tail call void asm sideeffect "", "~{d8},~{d9},~{d10},~{d12},~{d13},~{d14},~{d15}"() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Aligned spilling only works for contiguous ranges starting from d8.
|
|
|
|
; The rest goes to the standard vpush instructions.
|
|
|
|
; NEON: f3plus4
|
|
|
|
; NEON: push {r4, r7, lr}
|
|
|
|
; NEON: vpush {d12, d13, d14, d15}
|
|
|
|
; NEON: sub.w r4, sp, #24
|
2015-01-08 23:09:14 +08:00
|
|
|
; NEON: bfc r4, #0, #4
|
2011-12-23 08:36:18 +08:00
|
|
|
; Stack pointer must be updated before the spills.
|
|
|
|
; NEON: mov sp, r4
|
2013-02-22 18:01:33 +08:00
|
|
|
; NEON: vst1.64 {d8, d9}, [r4:128]
|
2011-12-23 08:36:18 +08:00
|
|
|
; NEON: vstr d10, [r4, #16]
|
|
|
|
; Epilog
|
|
|
|
; NEON: vld1.64 {d8, d9},
|
|
|
|
; NEON: vldr d10, [{{.*}}, #16]
|
|
|
|
; The stack pointer restore must happen after the reloads.
|
|
|
|
; NEON: mov sp,
|
|
|
|
; NEON: vpop {d12, d13, d14, d15}
|
|
|
|
; NEON: pop
|