1 ; RUN: llc --force-dwarf-frame-section %s -o - | FileCheck %s
2 ; RUN: llc --filetype=obj %s -o - | llvm-readelf -s --unwind - | FileCheck %s --check-prefix=UNWIND
3 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv7m-arm-none-eabi"
7 ; __attribute__((noinline)) int h(int a, int b) {
13 ; int f(int a, int b, int c, int d) {
17 ; return 2 + a * (a + b) / (c + d);
20 ; int g(int a, int b, int c, int d) {
24 ; return 1 + a * (a + b) / (c + d);
27 @_ZTIi = external dso_local constant ptr
29 define hidden i32 @_Z1hii(i32 %a, i32 %b) local_unnamed_addr #0 {
31 %cmp = icmp slt i32 %a, 0
32 br i1 %cmp, label %if.then, label %if.end
34 if.then: ; preds = %entry
35 %exception = tail call ptr @__cxa_allocate_exception(i32 4) #1
36 store i32 1, ptr %exception, align 8
37 tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #2
40 if.end: ; preds = %entry
41 %add = add nsw i32 %b, %a
45 ; CHECK-LABEL: _Z1hii:
47 ; CHECK: pac r12, lr, sp
48 ; CHECK-NEXT: .save {r7, lr}
49 ; CHECK-NEXT: push {r7, lr}
50 ; CHECK-NEXT: .cfi_def_cfa_offset 8
51 ; CHECK-NEXT: .cfi_offset lr, -4
52 ; CHECK-NEXT: .cfi_offset r7, -8
53 ; CHECK-NEXT: .save {ra_auth_code}
54 ; CHECK-NEXT: str r12, [sp, #-4]!
55 ; CHECK-NEXT: .cfi_def_cfa_offset 12
56 ; CHECK-NEXT: .cfi_offset ra_auth_code, -12
58 ; CHECK-NEXT: sub sp, #4
59 ; CHECK-NEXT: .cfi_def_cfa_offset 16
65 declare dso_local ptr @__cxa_allocate_exception(i32) local_unnamed_addr
67 declare dso_local void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr
69 define hidden i32 @_Z1fiiii(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
71 %cmp = icmp slt i32 %a, 0
72 br i1 %cmp, label %return, label %if.end
74 if.end: ; preds = %entry
75 %call = tail call i32 @_Z1hii(i32 %a, i32 %b)
76 %add = add nsw i32 %call, %b
77 %mul = mul nsw i32 %add, %call
78 %add1 = add nsw i32 %d, %c
79 %div = sdiv i32 %mul, %add1
80 %add2 = add nsw i32 %div, 2
83 return: ; preds = %entry, %if.end
84 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
88 ; CHECK-LABEL: _Z1fiiii:
90 ; CHECK: pac r12, lr, sp
91 ; CHECK-NEXT: .save {r4, r5, r6, lr}
92 ; CHECK-NEXT: push {r4, r5, r6, lr}
93 ; CHECK-NEXT: .cfi_def_cfa_offset 16
94 ; CHECK-NEXT: .cfi_offset lr, -4
95 ; CHECK-NEXT: .cfi_offset r6, -8
96 ; CHECK-NEXT: .cfi_offset r5, -12
97 ; CHECK-NEXT: .cfi_offset r4, -16
98 ; CHECK-NEXT: .save {ra_auth_code}
99 ; CHECK-NEXT: str r12, [sp, #-4]!
100 ; CHECK-NEXT: .cfi_def_cfa_offset 20
101 ; CHECK-NEXT: .cfi_offset ra_auth_code, -20
102 ; CHECK-NEXT: .pad #4
103 ; CHECK-NEXT: sub sp, #4
104 ; CHECK-NEXT: .cfi_def_cfa_offset 24
106 ; CHECK: bl OUTLINED_FUNCTION_0
109 ; CHECK-NEXT: ldr r12, [sp], #4
110 ; CHECK-NEXT: pop.w {r4, r5, r6, lr}
111 ; CHECK-NEXT: aut r12, lr, sp
116 define hidden i32 @_Z1giiii(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
118 %cmp = icmp slt i32 %a, 0
119 br i1 %cmp, label %return, label %if.end
121 if.end: ; preds = %entry
122 %call = tail call i32 @_Z1hii(i32 %a, i32 %b)
123 %add = add nsw i32 %call, %b
124 %mul = mul nsw i32 %add, %call
125 %add1 = add nsw i32 %d, %c
126 %div = sdiv i32 %mul, %add1
127 %add2 = add nsw i32 %div, 1
130 return: ; preds = %entry, %if.end
131 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
135 ; CHECK-LABEL: _Z1giiii:
137 ; CHECK: pac r12, lr, sp
138 ; CHECK-NEXT: .save {r4, r5, r6, lr}
139 ; CHECK-NEXT: push {r4, r5, r6, lr}
140 ; CHECK-NEXT: .cfi_def_cfa_offset 16
141 ; CHECK-NEXT: .cfi_offset lr, -4
142 ; CHECK-NEXT: .cfi_offset r6, -8
143 ; CHECK-NEXT: .cfi_offset r5, -12
144 ; CHECK-NEXT: .cfi_offset r4, -16
145 ; CHECK-NEXT: .save {ra_auth_code}
146 ; CHECK-NEXT: str r12, [sp, #-4]!
147 ; CHECK-NEXT: .cfi_def_cfa_offset 20
148 ; CHECK-NEXT: .cfi_offset ra_auth_code, -20
149 ; CHECK-NEXT: .pad #4
150 ; CHECK-NEXT: sub sp, #4
151 ; CHECK-NEXT: .cfi_def_cfa_offset 24
153 ; CHECK: bl OUTLINED_FUNCTION_0
156 ; CHECK-NEXT: ldr r12, [sp], #4
157 ; CHECK-NEXT: pop.w {r4, r5, r6, lr}
158 ; CHECK-NEXT: aut r12, lr, sp
162 ; CHEK-LABEL: OUTLINED_FUNCTION_0:
167 attributes #0 = { minsize noinline optsize "denormal-fp-math"="preserve-sign,preserve-sign" "denormal-fp-math-f32"="ieee,ieee" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="true" "no-jump-tables"="false" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="cortex-m3" "target-features"="+armv7-m,+hwdiv,+thumb-mode" "unsafe-fp-math"="false" "use-soft-float"="false" }
168 attributes #1 = { nounwind }
169 attributes #2 = { noreturn }
172 !llvm.module.flags = !{!0, !1, !2}
174 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
175 !1 = !{i32 8, !"sign-return-address", i32 1}
176 !2 = !{i32 8, !"sign-return-address-all", i32 0}
179 ; UNWIND-LABEL: FunctionAddress: 0x0
181 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
182 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
183 ; UNWIND-NEXT: 0x84 0x08 ; pop {r7, lr}
184 ; UNWIND-NEXT: 0xB0 ; finish
185 ; UNWIND-NEXT: 0xB0 ; finish
187 ; UNWIND-LABEL: FunctionAddress: 0x3C
189 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
190 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
191 ; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
193 ; UNWIND-LABEL: FunctionAddress: 0x72
195 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
196 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
197 ; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
199 ; UNWIND-LABEL: FunctionAddress: 0xA8
201 ; UNWIND-NEXT: 0xB0 ; finish
202 ; UNWIND-NEXT: 0xB0 ; finish
203 ; UNWIND-NEXT: 0xB0 ; finish
205 ; UNWIND: 000000a9 {{.*}} OUTLINED_FUNCTION_0
206 ; UWNIND: 00000001 {{.*}} _Z1hii
207 ; UWNIND: 0000003d {{.*}} _Z1fiiii
208 ; UWNIND: 00000073 {{.*}} _Z1giiii