1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc --force-dwarf-frame-section %s -o - | FileCheck %s
3 ; RUN: llc --filetype=obj %s -o - | llvm-readelf -s --unwind - | FileCheck %s --check-prefix=UNWIND
4 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
5 target triple = "thumbv7m-arm-none-eabi"
8 ; __attribute__((noinline)) int h(int a, int b) {
14 ; int f(int a, int b, int c, int d) {
18 ; return 2 + a * (a + b) / (c + d);
21 ; int g(int a, int b, int c, int d) {
25 ; return 1 + a * (a + b) / (c + d);
28 @_ZTIi = external dso_local constant ptr
30 define hidden i32 @_Z1hii(i32 %a, i32 %b) local_unnamed_addr #0 {
31 ; CHECK-LABEL: _Z1hii:
32 ; CHECK: .cfi_sections .debug_frame
33 ; CHECK-NEXT: .cfi_startproc
34 ; CHECK-NEXT: @ %bb.0: @ %entry
35 ; CHECK-NEXT: pac r12, lr, sp
36 ; CHECK-NEXT: .save {r7, ra_auth_code, lr}
38 ; CHECK-NEXT: push.w {r6, r7, r12, lr}
39 ; CHECK-NEXT: .cfi_def_cfa_offset 16
40 ; CHECK-NEXT: .cfi_offset lr, -4
41 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
42 ; CHECK-NEXT: .cfi_offset r7, -12
43 ; CHECK-NEXT: cmp.w r0, #-1
44 ; CHECK-NEXT: ble .LBB0_2
45 ; CHECK-NEXT: @ %bb.1: @ %if.end
46 ; CHECK-NEXT: add r0, r1
47 ; CHECK-NEXT: pop.w {r3, r7, r12, lr}
48 ; CHECK-NEXT: aut r12, lr, sp
50 ; CHECK-NEXT: .LBB0_2: @ %if.then
51 ; CHECK-NEXT: movs r0, #4
52 ; CHECK-NEXT: bl __cxa_allocate_exception
53 ; CHECK-NEXT: movs r1, #1
54 ; CHECK-NEXT: movs r2, #0
55 ; CHECK-NEXT: str r1, [r0]
56 ; CHECK-NEXT: ldr r1, .LCPI0_0
57 ; CHECK-NEXT: bl __cxa_throw
58 ; CHECK-NEXT: .p2align 2
59 ; CHECK-NEXT: @ %bb.3:
60 ; CHECK-NEXT: .LCPI0_0:
61 ; CHECK-NEXT: .long _ZTIi
63 %cmp = icmp slt i32 %a, 0
64 br i1 %cmp, label %if.then, label %if.end
66 if.then: ; preds = %entry
67 %exception = tail call ptr @__cxa_allocate_exception(i32 4) #1
68 store i32 1, ptr %exception, align 8
69 tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null) #2
72 if.end: ; preds = %entry
73 %add = add nsw i32 %b, %a
77 declare dso_local ptr @__cxa_allocate_exception(i32) local_unnamed_addr
79 declare dso_local void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr
81 define hidden i32 @_Z1fiiii(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
82 ; CHECK-LABEL: _Z1fiiii:
83 ; CHECK: .cfi_startproc
84 ; CHECK-NEXT: @ %bb.0: @ %entry
85 ; CHECK-NEXT: pac r12, lr, sp
86 ; CHECK-NEXT: .save {r4, r5, r6, ra_auth_code, lr}
88 ; CHECK-NEXT: push.w {r3, r4, r5, r6, r12, lr}
89 ; CHECK-NEXT: .cfi_def_cfa_offset 24
90 ; CHECK-NEXT: .cfi_offset lr, -4
91 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
92 ; CHECK-NEXT: .cfi_offset r6, -12
93 ; CHECK-NEXT: .cfi_offset r5, -16
94 ; CHECK-NEXT: .cfi_offset r4, -20
95 ; CHECK-NEXT: cmp r0, #0
96 ; CHECK-NEXT: bmi .LBB1_2
97 ; CHECK-NEXT: @ %bb.1: @ %if.end
98 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
99 ; CHECK-NEXT: adds r1, r0, r6
100 ; CHECK-NEXT: muls r0, r1, r0
101 ; CHECK-NEXT: adds r1, r4, r5
102 ; CHECK-NEXT: sdiv r0, r0, r1
103 ; CHECK-NEXT: adds r0, #2
104 ; CHECK-NEXT: b .LBB1_3
105 ; CHECK-NEXT: .LBB1_2:
106 ; CHECK-NEXT: mov.w r0, #-1
107 ; CHECK-NEXT: .LBB1_3: @ %return
108 ; CHECK-NEXT: pop.w {r3, r4, r5, r6, r12, lr}
109 ; CHECK-NEXT: aut r12, lr, sp
112 %cmp = icmp slt i32 %a, 0
113 br i1 %cmp, label %return, label %if.end
115 if.end: ; preds = %entry
116 %call = tail call i32 @_Z1hii(i32 %a, i32 %b)
117 %add = add nsw i32 %call, %b
118 %mul = mul nsw i32 %add, %call
119 %add1 = add nsw i32 %d, %c
120 %div = sdiv i32 %mul, %add1
121 %add2 = add nsw i32 %div, 2
124 return: ; preds = %entry, %if.end
125 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
129 define hidden i32 @_Z1giiii(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
130 ; CHECK-LABEL: _Z1giiii:
131 ; CHECK: .cfi_startproc
132 ; CHECK-NEXT: @ %bb.0: @ %entry
133 ; CHECK-NEXT: pac r12, lr, sp
134 ; CHECK-NEXT: .save {r4, r5, r6, ra_auth_code, lr}
135 ; CHECK-NEXT: .pad #4
136 ; CHECK-NEXT: push.w {r3, r4, r5, r6, r12, lr}
137 ; CHECK-NEXT: .cfi_def_cfa_offset 24
138 ; CHECK-NEXT: .cfi_offset lr, -4
139 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
140 ; CHECK-NEXT: .cfi_offset r6, -12
141 ; CHECK-NEXT: .cfi_offset r5, -16
142 ; CHECK-NEXT: .cfi_offset r4, -20
143 ; CHECK-NEXT: cmp r0, #0
144 ; CHECK-NEXT: bmi .LBB2_2
145 ; CHECK-NEXT: @ %bb.1: @ %if.end
146 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
147 ; CHECK-NEXT: adds r1, r0, r6
148 ; CHECK-NEXT: muls r0, r1, r0
149 ; CHECK-NEXT: adds r1, r4, r5
150 ; CHECK-NEXT: sdiv r0, r0, r1
151 ; CHECK-NEXT: adds r0, #1
152 ; CHECK-NEXT: b .LBB2_3
153 ; CHECK-NEXT: .LBB2_2:
154 ; CHECK-NEXT: mov.w r0, #-1
155 ; CHECK-NEXT: .LBB2_3: @ %return
156 ; CHECK-NEXT: pop.w {r3, r4, r5, r6, r12, lr}
157 ; CHECK-NEXT: aut r12, lr, sp
160 %cmp = icmp slt i32 %a, 0
161 br i1 %cmp, label %return, label %if.end
163 if.end: ; preds = %entry
164 %call = tail call i32 @_Z1hii(i32 %a, i32 %b)
165 %add = add nsw i32 %call, %b
166 %mul = mul nsw i32 %add, %call
167 %add1 = add nsw i32 %d, %c
168 %div = sdiv i32 %mul, %add1
169 %add2 = add nsw i32 %div, 1
172 return: ; preds = %entry, %if.end
173 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
177 ; CHEK-LABEL: OUTLINED_FUNCTION_0:
182 attributes #0 = { minsize noinline optsize "sign-return-address"="non-leaf" "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" }
183 attributes #1 = { nounwind "sign-return-address"="non-leaf" }
184 attributes #2 = { noreturn "sign-return-address"="non-leaf" }
187 !llvm.module.flags = !{!0, !1, !2}
189 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
190 !1 = !{i32 8, !"sign-return-address", i32 1}
191 !2 = !{i32 8, !"sign-return-address-all", i32 0}
194 ; UNWIND-LABEL: FunctionAddress: 0x0
196 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
197 ; UNWIND-NEXT: 0x80 0x08 ; pop {r7}
198 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
199 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
201 ; UNWIND-LABEL: FunctionAddress: 0x30
203 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
204 ; UNWIND-NEXT: 0xA2 ; pop {r4, r5, r6}
205 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
206 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
208 ; UNWIND-LABEL: FunctionAddress: 0x5C
210 ; UNWIND-NEXT: 0x00 ; vsp = vsp + 4
211 ; UNWIND-NEXT: 0xA2 ; pop {r4, r5, r6}
212 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
213 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
215 ; UNWIND-LABEL: FunctionAddress: 0x88
217 ; UNWIND-NEXT: 0xB0 ; finish
219 ; UNWIND: 00000089 {{.*}} OUTLINED_FUNCTION_0
220 ; UWNIND: 00000001 {{.*}} _Z1hii
221 ; UWNIND: 00000031 {{.*}} _Z1fiiii
222 ; UWNIND: 0000005d {{.*}} _Z1giiii