1 ; RUN: llc --force-dwarf-frame-section --exception-model=arm %s -o - | FileCheck %s
2 ; RUN: llc --filetype=obj %s --exception-model=arm -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"
5 ; Triple tweaked so we get 16-byte stack alignment and better test coverage.
6 target triple = "armv7m-none-nacl-android"
9 ; volatile int a, b, c, d, e, f, g, h, i;
12 ; int r = (a + b) / (c + d) + e + f / g + h + i;
17 ; int r = (a + b) / (c + d) + e + f / g + h + i;
21 @a = hidden global i32 0, align 4
22 @b = hidden global i32 0, align 4
23 @c = hidden global i32 0, align 4
24 @d = hidden global i32 0, align 4
25 @e = hidden global i32 0, align 4
26 @f = hidden global i32 0, align 4
27 @g = hidden global i32 0, align 4
28 @h = hidden global i32 0, align 4
29 @i = hidden global i32 0, align 4
32 define hidden i32 @x() local_unnamed_addr #0 {
34 %0 = load volatile i32, ptr @a, align 4
35 %1 = load volatile i32, ptr @b, align 4
36 %add = add nsw i32 %1, %0
37 %2 = load volatile i32, ptr @c, align 4
38 %3 = load volatile i32, ptr @d, align 4
39 %add1 = add nsw i32 %3, %2
40 %div = sdiv i32 %add, %add1
41 %4 = load volatile i32, ptr @e, align 4
42 %5 = load volatile i32, ptr @f, align 4
43 %6 = load volatile i32, ptr @g, align 4
44 %div3 = sdiv i32 %5, %6
45 %7 = load volatile i32, ptr @h, align 4
46 %8 = load volatile i32, ptr @i, align 4
47 %add2 = add i32 %div, 1
48 %add4 = add i32 %add2, %4
49 %add5 = add i32 %add4, %div3
50 %add6 = add i32 %add5, %7
51 %add7 = add i32 %add6, %8
56 ; CHECK: ldr r0, .LCPI0_0
57 ; CHECK-NEXT: pac r12, lr, sp
59 ; CHECK-NEXT: .save {ra_auth_code, lr}
60 ; CHECK-NEXT: strd r12, lr, [sp, #-16]!
61 ; CHECK-NEXT: .cfi_def_cfa_offset 16
62 ; CHECK-NEXT: .cfi_offset lr, -12
63 ; CHECK-NEXT: .cfi_offset ra_auth_code, -16
64 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
65 ; CHECK-NEXT: ldrd r12, lr, [sp], #16
66 ; CHECK-NEXT: .cfi_def_cfa_offset 0
67 ; CHECK-NEXT: .cfi_restore lr
68 ; CHECK-NEXT: .cfi_undefined ra_auth_code
69 ; CHECK-NEXT: aut r12, lr, sp
70 ; CHECK-NEXT: adds r0, #1
73 define hidden i32 @y() local_unnamed_addr #0 {
75 %0 = load volatile i32, ptr @a, align 4
76 %1 = load volatile i32, ptr @b, align 4
77 %add = add nsw i32 %1, %0
78 %2 = load volatile i32, ptr @c, align 4
79 %3 = load volatile i32, ptr @d, align 4
80 %add1 = add nsw i32 %3, %2
81 %div = sdiv i32 %add, %add1
82 %4 = load volatile i32, ptr @e, align 4
83 %5 = load volatile i32, ptr @f, align 4
84 %6 = load volatile i32, ptr @g, align 4
85 %div3 = sdiv i32 %5, %6
86 %7 = load volatile i32, ptr @h, align 4
87 %8 = load volatile i32, ptr @i, align 4
88 %add2 = add i32 %div, 2
89 %add4 = add i32 %add2, %4
90 %add5 = add i32 %add4, %div3
91 %add6 = add i32 %add5, %7
92 %add7 = add i32 %add6, %8
96 ; CHECK: ldr r0, .LCPI1_0
97 ; CHECK-NEXT: pac r12, lr, sp
99 ; CHECK-NEXT: .save {ra_auth_code, lr}
100 ; CHECK-NEXT: strd r12, lr, [sp, #-16]!
101 ; CHECK-NEXT: .cfi_def_cfa_offset 16
102 ; CHECK-NEXT: .cfi_offset lr, -12
103 ; CHECK-NEXT: .cfi_offset ra_auth_code, -16
104 ; CHECK-NEXT: bl OUTLINED_FUNCTION_0
105 ; CHECK-NEXT: ldrd r12, lr, [sp], #16
106 ; CHECK-NEXT: .cfi_def_cfa_offset 0
107 ; CHECK-NEXT: .cfi_restore lr
108 ; CHECK-NEXT: .cfi_undefined ra_auth_code
109 ; CHECK-NEXT: aut r12, lr, sp
110 ; CHECK-NEXT: adds r0, #2
113 ; CHECK-LABEL: OUTLINED_FUNCTION_0:
119 attributes #0 = { minsize nofree norecurse nounwind optsize uwtable "sign-return-address"="non-leaf"}
121 !llvm.module.flags = !{!0, !1, !2}
123 !0 = !{i32 8, !"branch-target-enforcement", i32 0}
124 !1 = !{i32 8, !"sign-return-address", i32 1}
125 !2 = !{i32 8, !"sign-return-address-all", i32 0}
127 ; UNWIND-LABEL: FunctionAddress: 0x0
128 ; UNWIND: 0xB4 ; pop ra_auth_code
129 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
130 ; UNWIND-NEXT: 0x01 ; vsp = vsp + 8
131 ; UNWIND-NEXT: 0xB0 ; finish
133 ; UNWIND-LABEL: FunctionAddress: 0x20
134 ; UNWIND: 0xB4 ; pop ra_auth_code
135 ; UNWIND-NEXT: 0x84 0x00 ; pop {lr}
136 ; UNWIND-NEXT: 0x01 ; vsp = vsp + 8
137 ; UNWIND-NEXT: 0xB0 ; finish
139 ; UNWIND-LABEL: FunctionAddress: 0x40
141 ; UNWIND-NEXT: 0xB0 ; finish
144 ; UNWINND-LABEL: 00000041 {{.*}} OUTLINED_FUNCTION_0
145 ; UNWINND-LABEL: 00000001 {{.*}} x
146 ; UNWINND-LABEL: 00000021 {{.*}} y