diff options
| author | Oliver Stannard <oliver.stannard@arm.com> | 2016-08-23 09:19:22 +0000 |
|---|---|---|
| committer | Oliver Stannard <oliver.stannard@arm.com> | 2016-08-23 09:19:22 +0000 |
| commit | 9aa6f010a4438d579016f84302311b9992d0a0e1 (patch) | |
| tree | 589d8030ab8a499572fbbf670f584d38501317c2 /llvm/test/CodeGen/ARM/v7k-abi-align.ll | |
| parent | 49280f6c59b1d7fe361bfd542df704ff91954e32 (diff) | |
| download | bcm5719-llvm-9aa6f010a4438d579016f84302311b9992d0a0e1.tar.gz bcm5719-llvm-9aa6f010a4438d579016f84302311b9992d0a0e1.zip | |
[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
Diffstat (limited to 'llvm/test/CodeGen/ARM/v7k-abi-align.ll')
| -rw-r--r-- | llvm/test/CodeGen/ARM/v7k-abi-align.ll | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/llvm/test/CodeGen/ARM/v7k-abi-align.ll b/llvm/test/CodeGen/ARM/v7k-abi-align.ll index e9b67f22edf..a5cdb8f8982 100644 --- a/llvm/test/CodeGen/ARM/v7k-abi-align.ll +++ b/llvm/test/CodeGen/ARM/v7k-abi-align.ll @@ -2,25 +2,25 @@ %struct = type { i8, i64, i8, double, i8, <2 x float>, i8, <4 x float> } -define i32 @test_i64_align() { +define i32 @test_i64_align() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_i64_align: ; CHECL: movs r0, #8 ret i32 ptrtoint(i64* getelementptr(%struct, %struct* null, i32 0, i32 1) to i32) } -define i32 @test_f64_align() { +define i32 @test_f64_align() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_f64_align: ; CHECL: movs r0, #24 ret i32 ptrtoint(double* getelementptr(%struct, %struct* null, i32 0, i32 3) to i32) } -define i32 @test_v2f32_align() { +define i32 @test_v2f32_align() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_v2f32_align: ; CHECL: movs r0, #40 ret i32 ptrtoint(<2 x float>* getelementptr(%struct, %struct* null, i32 0, i32 5) to i32) } -define i32 @test_v4f32_align() { +define i32 @test_v4f32_align() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_v4f32_align: ; CHECL: movs r0, #64 ret i32 ptrtoint(<4 x float>* getelementptr(%struct, %struct* null, i32 0, i32 7) to i32) @@ -28,7 +28,7 @@ define i32 @test_v4f32_align() { ; Key point here is than an extra register has to be saved so that the DPRs end ; up in an aligned location (as prologue/epilogue inserter had calculated). -define void @test_dpr_unwind_align() { +define void @test_dpr_unwind_align() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_dpr_unwind_align: ; CHECK: push {r5, r6, r7, lr} ; CHECK-NOT: sub sp @@ -51,7 +51,7 @@ define void @test_dpr_unwind_align() { ; This time, there's no viable way to tack CS-registers onto the list: a real SP ; adjustment needs to be performed to put d8 and d9 where they should be. -define void @test_dpr_unwind_align_manually() { +define void @test_dpr_unwind_align_manually() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_dpr_unwind_align_manually: ; CHECK: push {r4, r5, r6, r7, lr} ; CHECK-NOT: sub sp @@ -76,7 +76,7 @@ define void @test_dpr_unwind_align_manually() { } ; If there's only a CS1 area, the sub should be in the right place: -define void @test_dpr_unwind_align_just_cs1() { +define void @test_dpr_unwind_align_just_cs1() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_dpr_unwind_align_just_cs1: ; CHECK: push {r4, r5, r6, r7, lr} ; CHECK: sub sp, #4 @@ -99,7 +99,7 @@ define void @test_dpr_unwind_align_just_cs1() { } ; If there are no DPRs, we shouldn't try to align the stack in stages anyway -define void @test_dpr_unwind_align_no_dprs() { +define void @test_dpr_unwind_align_no_dprs() "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_dpr_unwind_align_no_dprs: ; CHECK: push {r4, r5, r6, r7, lr} ; CHECK: sub sp, #12 @@ -117,7 +117,7 @@ define void @test_dpr_unwind_align_no_dprs() { ; 128-bit vectors should use 128-bit (i.e. correctly aligned) slots on ; the stack. -define <4 x float> @test_v128_stack_pass([8 x double], float, <4 x float> %in) { +define <4 x float> @test_v128_stack_pass([8 x double], float, <4 x float> %in) "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_v128_stack_pass: ; CHECK: add r[[ADDR:[0-9]+]], sp, #16 ; CHECK: vld1.64 {d0, d1}, [r[[ADDR]]:128] @@ -129,7 +129,7 @@ declare void @varargs(i32, ...) ; When varargs are enabled, we go down a different route. Still want 128-bit ; alignment though. -define void @test_v128_stack_pass_varargs(<4 x float> %in) { +define void @test_v128_stack_pass_varargs(<4 x float> %in) "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_v128_stack_pass_varargs: ; CHECK: add r[[ADDR:[0-9]+]], sp, #16 ; CHECK: vst1.64 {d0, d1}, [r[[ADDR]]:128] @@ -140,7 +140,7 @@ define void @test_v128_stack_pass_varargs(<4 x float> %in) { ; To be compatible with AAPCS's va_start model (store r0-r3 at incoming SP, give ; a single pointer), 64-bit quantities must be pass -define i64 @test_64bit_gpr_align(i32, i64 %r2_r3, i32 %sp) { +define i64 @test_64bit_gpr_align(i32, i64 %r2_r3, i32 %sp) "no-frame-pointer-elim"="true" { ; CHECK-LABEL: test_64bit_gpr_align: ; CHECK: ldr [[RHS:r[0-9]+]], [sp] ; CHECK: adds r0, [[RHS]], r2 |

