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) { return a + b; }
9 ; int f(int a, int b, int c, int d) {
12 ; a = h(11 * a - b, b);
13 ; return 2 + a * (a + b) / (c + d);
16 ; int g(int a, int b, int c, int d) {
19 ; a = h(11 * a - b, b);
20 ; return 1 + a * (a + b) / (c + d);
23 define hidden i32 @h(i32 %a, i32 %b) local_unnamed_addr #0 {
25 %add = add nsw i32 %b, %a
29 define hidden i32 @f(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
31 %cmp = icmp slt i32 %a, 0
32 br i1 %cmp, label %return, label %if.end
34 if.end: ; preds = %entry
35 %mul = mul nsw i32 %a, 11
36 %xor = xor i32 %mul, 100
37 %sub = sub nsw i32 %xor, %b
38 %call = tail call i32 @h(i32 %sub, i32 %b)
39 %add = add nsw i32 %call, %b
40 %mul1 = mul nsw i32 %add, %call
41 %add2 = add nsw i32 %d, %c
42 %div = sdiv i32 %mul1, %add2
43 %add3 = add nsw i32 %div, 2
46 return: ; preds = %entry, %if.end
47 %retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
53 ; CHECK: pac r12, lr, sp
54 ; CHECK-NEXT: .save {r4, r5, r6, lr}
55 ; CHECK-NEXT: push {r4, r5, r6, lr}
56 ; CHECK-NEXT: .cfi_def_cfa_offset 16
57 ; CHECK-NEXT: .cfi_offset lr, -4
58 ; CHECK-NEXT: .cfi_offset r6, -8
59 ; CHECK-NEXT: .cfi_offset r5, -12
60 ; CHECK-NEXT: .cfi_offset r4, -16
61 ; CHECK-NEXT: .save {ra_auth_code}
62 ; CHECK-NEXT: str r12, [sp, #-4]!
63 ; CHECK-NEXT: .cfi_def_cfa_offset 20
64 ; CHECK-NEXT: .cfi_offset ra_auth_code, -20
66 ; CHECK-NEXT: sub sp, #4
67 ; CHECK-NEXT: .cfi_def_cfa_offset 24
69 ; CHECK: bl OUTLINED_FUNCTION_0
72 ; CHECK-NEXT: ldr r12, [sp], #4
73 ; CHECK-NEXT: pop.w {r4, r5, r6, lr}
74 ; CHECK-NEXT: aut r12, lr, sp
78 define hidden i32 @g(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
80 %cmp = icmp slt i32 %a, 0
81 br i1 %cmp, label %return, label %if.end
83 if.end: ; preds = %entry
84 %mul = mul nsw i32 %a, 11
85 %xor = xor i32 %mul, 100
86 %sub = sub nsw i32 %xor, %b
87 %call = tail call i32 @h(i32 %sub, i32 %b)
88 %add = add nsw i32 %call, %b
89 %mul1 = mul nsw i32 %add, %call
90 %add2 = add nsw i32 %d, %c
91 %div = sdiv i32 %mul1, %add2
92 %add3 = add nsw i32 %div, 1
95 return: ; preds = %entry, %if.end
96 %retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
100 ; CHECK: pac r12, lr, sp
101 ; CHECK-NEXT: .save {r4, r5, r6, lr}
102 ; CHECK-NEXT: push {r4, r5, r6, lr}
103 ; CHECK-NEXT: .cfi_def_cfa_offset 16
104 ; CHECK-NEXT: .cfi_offset lr, -4
105 ; CHECK-NEXT: .cfi_offset r6, -8
106 ; CHECK-NEXT: .cfi_offset r5, -12
107 ; CHECK-NEXT: .cfi_offset r4, -16
108 ; CHECK-NEXT: .save {ra_auth_code}
109 ; CHECK-NEXT: str r12, [sp, #-4]!
110 ; CHECK-NEXT: .cfi_def_cfa_offset 20
111 ; CHECK-NEXT: .cfi_offset ra_auth_code, -20
112 ; CHECK-NEXT: .pad #4
113 ; CHECK-NEXT: sub sp, #4
114 ; CHECK-NEXT: .cfi_def_cfa_offset 24
116 ; CHECK: bl OUTLINED_FUNCTION_0
119 ; CHECK-NEXT: ldr r12, [sp], #4
120 ; CHECK-NEXT: pop.w {r4, r5, r6, lr}
121 ; CHECK-NEXT: aut r12, lr, sp
124 ; CHECK-LABEL: OUTLINED_FUNCTION_0:
125 ; CHECK: pac r12, lr, sp
126 ; CHECK-NEXT: .save {ra_auth_code, lr}
127 ; CHECK-NEXT: strd r12, lr, [sp, #-8]!
128 ; CHECK-NEXT: .cfi_def_cfa_offset 8
129 ; CHECK-NEXT: .cfi_offset lr, -4
130 ; CHECK-NEXT: .cfi_offset ra_auth_code, -8
132 ; CHECK: ldrd r12, lr, [sp], #8
133 ; CHECK-NEXT: .cfi_def_cfa_offset 0
134 ; CHECK-NEXT: .cfi_restore lr
135 ; CHECK-NEXT: .cfi_undefined ra_auth_code
136 ; CHECK-NEXT: aut r12, lr, sp
139 attributes #0 = { minsize noinline norecurse nounwind optsize readnone uwtable "sign-return-address"="non-leaf" }
141 !llvm.module.flags = !{!0, !1, !2}
143 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
144 !1 = !{i32 8, !"sign-return-address", i32 1}
145 !2 = !{i32 8, !"sign-return-address-all", i32 0}
148 ; UNWIND-LABEL: FunctionAddress: 0x4
149 ; UNWIND: 0x00 ; vsp = vsp + 4
150 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
151 ; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
153 ; UNWIND-LABEL: FunctionAddress: 0x30
154 ; UNWIND: 0x00 ; vsp = vsp + 4
155 ; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
156 ; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
158 ; UNWIND-LABEL: FunctionAddress: 0x5C
159 ; UNWIND: 0xB4 ; pop ra_auth_code
160 ; UNWIND: 0x84 0x00 ; pop {lr}
162 ; UNWIND-LABEL: 0000005d {{.*}} OUTLINED_FUNCTION_0
163 ; UNWIND-LABEL: 00000005 {{.*}} f
164 ; UNWIND-LABEL: 00000031 {{.*}} g