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) { return a + b; }
10 ; int f(int a, int b, int c, int d) {
13 ; a = h(11 * a - b, b);
14 ; return 2 + a * (a + b) / (c + d);
17 ; int g(int a, int b, int c, int d) {
20 ; a = h(11 * a - b, b);
21 ; return 1 + a * (a + b) / (c + d);
24 define hidden i32 @h(i32 %a, i32 %b) local_unnamed_addr #0 {
26 ; CHECK: .cfi_sections .debug_frame
27 ; CHECK-NEXT: .cfi_startproc
28 ; CHECK-NEXT: @ %bb.0: @ %entry
29 ; CHECK-NEXT: add r0, r1
32 %add = add nsw i32 %b, %a
36 define hidden i32 @f(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
38 ; CHECK: .cfi_startproc
39 ; CHECK-NEXT: @ %bb.0: @ %entry
40 ; CHECK-NEXT: pac r12, lr, sp
41 ; CHECK-NEXT: .save {r4, r5, r6, ra_auth_code, lr}
43 ; CHECK-NEXT: push.w {r3, r4, r5, r6, r12, lr}
44 ; CHECK-NEXT: .cfi_def_cfa_offset 24
45 ; CHECK-NEXT: .cfi_offset lr, -4
46 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
47 ; CHECK-NEXT: .cfi_offset r6, -12
48 ; CHECK-NEXT: .cfi_offset r5, -16
49 ; CHECK-NEXT: .cfi_offset r4, -20
50 ; CHECK-NEXT: cmp r0, #0
51 ; CHECK-NEXT: bmi .LBB1_2
52 ; CHECK-NEXT: @ %bb.1: @ %if.end
53 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
54 ; CHECK-NEXT: adds r0, #2
55 ; CHECK-NEXT: b .LBB1_3
56 ; CHECK-NEXT: .LBB1_2:
57 ; CHECK-NEXT: mov.w r0, #-1
58 ; CHECK-NEXT: .LBB1_3: @ %return
59 ; CHECK-NEXT: pop.w {r3, r4, r5, r6, r12, lr}
60 ; CHECK-NEXT: aut r12, lr, sp
63 %cmp = icmp slt i32 %a, 0
64 br i1 %cmp, label %return, label %if.end
66 if.end: ; preds = %entry
67 %mul = mul nsw i32 %a, 11
68 %xor = xor i32 %mul, 100
69 %sub = sub nsw i32 %xor, %b
70 %call = tail call i32 @h(i32 %sub, i32 %b)
71 %add = add nsw i32 %call, %b
72 %mul1 = mul nsw i32 %add, %call
73 %add2 = add nsw i32 %d, %c
74 %div = sdiv i32 %mul1, %add2
75 %add3 = add nsw i32 %div, 2
78 return: ; preds = %entry, %if.end
79 %retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
83 define hidden i32 @g(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
85 ; CHECK: .cfi_startproc
86 ; CHECK-NEXT: @ %bb.0: @ %entry
87 ; CHECK-NEXT: pac r12, lr, sp
88 ; CHECK-NEXT: .save {r4, r5, r6, ra_auth_code, lr}
90 ; CHECK-NEXT: push.w {r3, r4, r5, r6, r12, lr}
91 ; CHECK-NEXT: .cfi_def_cfa_offset 24
92 ; CHECK-NEXT: .cfi_offset lr, -4
93 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
94 ; CHECK-NEXT: .cfi_offset r6, -12
95 ; CHECK-NEXT: .cfi_offset r5, -16
96 ; CHECK-NEXT: .cfi_offset r4, -20
97 ; CHECK-NEXT: cmp r0, #0
98 ; CHECK-NEXT: bmi .LBB2_2
99 ; CHECK-NEXT: @ %bb.1: @ %if.end
100 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
101 ; CHECK-NEXT: adds r0, #1
102 ; CHECK-NEXT: b .LBB2_3
103 ; CHECK-NEXT: .LBB2_2:
104 ; CHECK-NEXT: mov.w r0, #-1
105 ; CHECK-NEXT: .LBB2_3: @ %return
106 ; CHECK-NEXT: pop.w {r3, r4, r5, r6, r12, lr}
107 ; CHECK-NEXT: aut r12, lr, sp
110 %cmp = icmp slt i32 %a, 0
111 br i1 %cmp, label %return, label %if.end
113 if.end: ; preds = %entry
114 %mul = mul nsw i32 %a, 11
115 %xor = xor i32 %mul, 100
116 %sub = sub nsw i32 %xor, %b
117 %call = tail call i32 @h(i32 %sub, i32 %b)
118 %add = add nsw i32 %call, %b
119 %mul1 = mul nsw i32 %add, %call
120 %add2 = add nsw i32 %d, %c
121 %div = sdiv i32 %mul1, %add2
122 %add3 = add nsw i32 %div, 1
125 return: ; preds = %entry, %if.end
126 %retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
130 ; CHECK-LABEL: OUTLINED_FUNCTION_0:
131 ; CHECK: pac r12, lr, sp
132 ; CHECK-NEXT: .save {ra_auth_code, lr}
133 ; CHECK-NEXT: strd r12, lr, [sp, #-8]!
134 ; CHECK-NEXT: .cfi_def_cfa_offset 8
135 ; CHECK-NEXT: .cfi_offset lr, -4
136 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
138 ; CHECK: ldrd r12, lr, [sp], #8
139 ; CHECK-NEXT: .cfi_def_cfa_offset 0
140 ; CHECK-NEXT: .cfi_restore lr
141 ; CHECK-NEXT: .cfi_undefined ra_auth_code
142 ; CHECK-NEXT: aut r12, lr, sp
145 attributes #0 = { minsize noinline norecurse nounwind optsize readnone uwtable "sign-return-address"="non-leaf" }
147 !llvm.module.flags = !{!0, !1, !2}
149 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
150 !1 = !{i32 8, !"sign-return-address", i32 1}
151 !2 = !{i32 8, !"sign-return-address-all", i32 0}
154 ; UNWIND-LABEL: FunctionAddress: 0x4
155 ; UNWIND: 0x00 ; vsp = vsp + 4
156 ; UNWIND-NEXT: 0xA2 ; pop {r4, r5, r6}
157 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
158 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
160 ; UNWIND-LABEL: FunctionAddress: 0x26
161 ; UNWIND: 0x00 ; vsp = vsp + 4
162 ; UNWIND-NEXT: 0xA2 ; pop {r4, r5, r6}
163 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
164 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
166 ; UNWIND-LABEL: FunctionAddress: 0x48
167 ; UNWIND: 0xB4 ; pop ra_auth_code
168 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
170 ; UNWIND-LABEL: 00000049 {{.*}} OUTLINED_FUNCTION_0
171 ; UNWIND-LABEL: 00000005 {{.*}} f
172 ; UNWIND-LABEL: 00000027 {{.*}} g