xref: /aosp_15_r20/external/llvm/test/CodeGen/ARM/dwarf-unwind.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=thumbv7-netbsd-eabi -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Workerdeclare void @bar()
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; ARM's frame lowering attempts to tack another callee-saved register onto the
5*9880d681SAndroid Build Coastguard Worker; list when it detects a potential misaligned VFP store. However, if there are
6*9880d681SAndroid Build Coastguard Worker; none available it used to just vpush anyway and misreport the location of the
7*9880d681SAndroid Build Coastguard Worker; registers in unwind info. Since there are benefits to aligned stores, it's
8*9880d681SAndroid Build Coastguard Worker; better to correct the code than the .cfi_offset directive.
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine void @test_dpr_align(i8 %l, i8 %r) {
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_dpr_align:
12*9880d681SAndroid Build Coastguard Worker; CHECK: push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr}
13*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 36
14*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, #4
15*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 40
16*9880d681SAndroid Build Coastguard Worker; CHECK: vpush {d8}
17*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset d8, -48
18*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp
19*9880d681SAndroid Build Coastguard Worker; [...]
20*9880d681SAndroid Build Coastguard Worker; CHECK: bl bar
21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: add sp
22*9880d681SAndroid Build Coastguard Worker; CHECK: vpop {d8}
23*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, #4
24*9880d681SAndroid Build Coastguard Worker; CHECK: pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc}
25*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "", "~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{d8}"()
26*9880d681SAndroid Build Coastguard Worker  call void @bar()
27*9880d681SAndroid Build Coastguard Worker  ret void
28*9880d681SAndroid Build Coastguard Worker}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; The prologue (but not the epilogue) can be made more space efficient by
31*9880d681SAndroid Build Coastguard Worker; chucking an argument register into the list. Not worth it in general though,
32*9880d681SAndroid Build Coastguard Worker; "sub sp, #4" is likely faster.
33*9880d681SAndroid Build Coastguard Workerdefine void @test_dpr_align_tiny(i8 %l, i8 %r) minsize {
34*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_dpr_align_tiny:
35*9880d681SAndroid Build Coastguard Worker; CHECK: push.w {r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
36*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp
37*9880d681SAndroid Build Coastguard Worker; CHECK: vpush {d8}
38*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_offset d8, -48
39*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp
40*9880d681SAndroid Build Coastguard Worker; [...]
41*9880d681SAndroid Build Coastguard Worker; CHECK: bl bar
42*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: add sp
43*9880d681SAndroid Build Coastguard Worker; CHECK: vpop {d8}
44*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, #4
45*9880d681SAndroid Build Coastguard Worker; CHECK: pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc}
46*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "", "~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{d8}"()
47*9880d681SAndroid Build Coastguard Worker  call void @bar()
48*9880d681SAndroid Build Coastguard Worker  ret void
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; However, we shouldn't do a 2-step align/adjust if there are no DPRs to be
53*9880d681SAndroid Build Coastguard Worker; saved.
54*9880d681SAndroid Build Coastguard Workerdefine void @test_nodpr_noalign(i8 %l, i8 %r) {
55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_nodpr_noalign:
56*9880d681SAndroid Build Coastguard Worker; CHECK: push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr}
57*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp
58*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, #12
59*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sub sp
60*9880d681SAndroid Build Coastguard Worker; [...]
61*9880d681SAndroid Build Coastguard Worker; CHECK: bl bar
62*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: add sp
63*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, #12
64*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: add sp
65*9880d681SAndroid Build Coastguard Worker; CHECK: pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc}
66*9880d681SAndroid Build Coastguard Worker  alloca i64
67*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "", "~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11}"()
68*9880d681SAndroid Build Coastguard Worker  call void @bar()
69*9880d681SAndroid Build Coastguard Worker  ret void
70*9880d681SAndroid Build Coastguard Worker}
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Workerdefine void @test_frame_pointer_offset() minsize "no-frame-pointer-elim"="true" {
73*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_frame_pointer_offset:
74*9880d681SAndroid Build Coastguard Worker; CHECK: push.w {r3, r4, r5, r6, r7, r8, r9, r10, r11, lr}
75*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa_offset 40
76*9880d681SAndroid Build Coastguard Worker; CHECK: add r7, sp, #16
77*9880d681SAndroid Build Coastguard Worker; CHECK: .cfi_def_cfa r7, 24
78*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: .cfi_def_cfa_offset
79*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "", "~{r4},~{r5},~{r6},~{r7},~{r8},~{r9},~{r10},~{r11},~{d8}"()
80*9880d681SAndroid Build Coastguard Worker  call void @bar()
81*9880d681SAndroid Build Coastguard Worker  ret void
82*9880d681SAndroid Build Coastguard Worker}