1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=aarch64-unknown-linux < %s | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -mtriple=arm64-apple-ios < %s | FileCheck %s --check-prefix=CHECK-APPLE
5 ; Check CSR split can work properly for tests below.
7 @a = common dso_local local_unnamed_addr global i32 0, align 4
9 define dso_local signext i32 @test1(ptr %b) local_unnamed_addr uwtable {
11 ; CHECK: // %bb.0: // %entry
12 ; CHECK-NEXT: adrp x8, a
13 ; CHECK-NEXT: ldrsw x8, [x8, :lo12:a]
14 ; CHECK-NEXT: cmp x8, x0
15 ; CHECK-NEXT: b.eq .LBB0_2
16 ; CHECK-NEXT: // %bb.1: // %if.end
18 ; CHECK-NEXT: .LBB0_2: // %if.then
19 ; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
20 ; CHECK-NEXT: .cfi_def_cfa_offset 16
21 ; CHECK-NEXT: .cfi_offset w19, -8
22 ; CHECK-NEXT: .cfi_offset w30, -16
23 ; CHECK-NEXT: mov x19, x0
24 ; CHECK-NEXT: bl callVoid
25 ; CHECK-NEXT: mov x0, x19
26 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
27 ; CHECK-NEXT: .cfi_def_cfa_offset 0
28 ; CHECK-NEXT: .cfi_restore w19
29 ; CHECK-NEXT: .cfi_restore w30
30 ; CHECK-NEXT: b callNonVoid
32 ; CHECK-APPLE-LABEL: test1:
33 ; CHECK-APPLE: ; %bb.0: ; %entry
34 ; CHECK-APPLE-NEXT: Lloh0:
35 ; CHECK-APPLE-NEXT: adrp x8, _a@PAGE
36 ; CHECK-APPLE-NEXT: Lloh1:
37 ; CHECK-APPLE-NEXT: ldrsw x8, [x8, _a@PAGEOFF]
38 ; CHECK-APPLE-NEXT: cmp x8, x0
39 ; CHECK-APPLE-NEXT: b.eq LBB0_2
40 ; CHECK-APPLE-NEXT: ; %bb.1: ; %if.end
41 ; CHECK-APPLE-NEXT: ret
42 ; CHECK-APPLE-NEXT: LBB0_2: ; %if.then
43 ; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill
44 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32
45 ; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill
46 ; CHECK-APPLE-NEXT: .cfi_offset w30, -8
47 ; CHECK-APPLE-NEXT: .cfi_offset w29, -16
48 ; CHECK-APPLE-NEXT: .cfi_offset w19, -24
49 ; CHECK-APPLE-NEXT: .cfi_offset w20, -32
50 ; CHECK-APPLE-NEXT: mov x19, x0
51 ; CHECK-APPLE-NEXT: bl _callVoid
52 ; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
53 ; CHECK-APPLE-NEXT: mov x0, x19
54 ; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload
55 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 0
56 ; CHECK-APPLE-NEXT: .cfi_restore w30
57 ; CHECK-APPLE-NEXT: .cfi_restore w29
58 ; CHECK-APPLE-NEXT: .cfi_restore w19
59 ; CHECK-APPLE-NEXT: .cfi_restore w20
60 ; CHECK-APPLE-NEXT: b _callNonVoid
61 ; CHECK-APPLE-NEXT: .loh AdrpLdr Lloh0, Lloh1
63 %0 = load i32, ptr @a, align 4, !tbaa !2
64 %conv = sext i32 %0 to i64
65 %1 = inttoptr i64 %conv to ptr
66 %cmp = icmp eq ptr %1, %b
67 br i1 %cmp, label %if.then, label %if.end
69 if.then: ; preds = %entry
70 %call = tail call signext i32 @callVoid()
71 %call2 = tail call signext i32 @callNonVoid(ptr %b)
74 if.end: ; preds = %if.then, %entry
75 %retval.0 = phi i32 [ %call2, %if.then ], [ undef, %entry ]
79 declare signext i32 @callVoid(...) local_unnamed_addr
81 declare signext i32 @callNonVoid(ptr) local_unnamed_addr
83 define dso_local signext i32 @test2(ptr %p1) local_unnamed_addr uwtable {
85 ; CHECK: // %bb.0: // %entry
86 ; CHECK-NEXT: stp x30, x19, [sp, #-16]! // 16-byte Folded Spill
87 ; CHECK-NEXT: .cfi_def_cfa_offset 16
88 ; CHECK-NEXT: .cfi_offset w19, -8
89 ; CHECK-NEXT: .cfi_offset w30, -16
90 ; CHECK-NEXT: .cfi_remember_state
91 ; CHECK-NEXT: cbz x0, .LBB1_3
92 ; CHECK-NEXT: // %bb.1: // %entry
93 ; CHECK-NEXT: adrp x8, a
94 ; CHECK-NEXT: mov x19, x0
95 ; CHECK-NEXT: ldrsw x8, [x8, :lo12:a]
96 ; CHECK-NEXT: cmp x8, x0
97 ; CHECK-NEXT: b.ne .LBB1_3
98 ; CHECK-NEXT: // %bb.2: // %if.then2
99 ; CHECK-NEXT: bl callVoid
100 ; CHECK-NEXT: mov x0, x19
101 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
102 ; CHECK-NEXT: .cfi_def_cfa_offset 0
103 ; CHECK-NEXT: .cfi_restore w19
104 ; CHECK-NEXT: .cfi_restore w30
105 ; CHECK-NEXT: b callNonVoid
106 ; CHECK-NEXT: .LBB1_3: // %return
107 ; CHECK-NEXT: .cfi_restore_state
108 ; CHECK-NEXT: mov w0, wzr
109 ; CHECK-NEXT: ldp x30, x19, [sp], #16 // 16-byte Folded Reload
110 ; CHECK-NEXT: .cfi_def_cfa_offset 0
111 ; CHECK-NEXT: .cfi_restore w19
112 ; CHECK-NEXT: .cfi_restore w30
115 ; CHECK-APPLE-LABEL: test2:
116 ; CHECK-APPLE: ; %bb.0: ; %entry
117 ; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill
118 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32
119 ; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill
120 ; CHECK-APPLE-NEXT: .cfi_offset w30, -8
121 ; CHECK-APPLE-NEXT: .cfi_offset w29, -16
122 ; CHECK-APPLE-NEXT: .cfi_offset w19, -24
123 ; CHECK-APPLE-NEXT: .cfi_offset w20, -32
124 ; CHECK-APPLE-NEXT: .cfi_remember_state
125 ; CHECK-APPLE-NEXT: cbz x0, LBB1_3
126 ; CHECK-APPLE-NEXT: ; %bb.1: ; %entry
127 ; CHECK-APPLE-NEXT: Lloh2:
128 ; CHECK-APPLE-NEXT: adrp x8, _a@PAGE
129 ; CHECK-APPLE-NEXT: mov x19, x0
130 ; CHECK-APPLE-NEXT: Lloh3:
131 ; CHECK-APPLE-NEXT: ldrsw x8, [x8, _a@PAGEOFF]
132 ; CHECK-APPLE-NEXT: cmp x8, x0
133 ; CHECK-APPLE-NEXT: b.ne LBB1_3
134 ; CHECK-APPLE-NEXT: ; %bb.2: ; %if.then2
135 ; CHECK-APPLE-NEXT: bl _callVoid
136 ; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
137 ; CHECK-APPLE-NEXT: mov x0, x19
138 ; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload
139 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 0
140 ; CHECK-APPLE-NEXT: .cfi_restore w30
141 ; CHECK-APPLE-NEXT: .cfi_restore w29
142 ; CHECK-APPLE-NEXT: .cfi_restore w19
143 ; CHECK-APPLE-NEXT: .cfi_restore w20
144 ; CHECK-APPLE-NEXT: b _callNonVoid
145 ; CHECK-APPLE-NEXT: LBB1_3: ; %return
146 ; CHECK-APPLE-NEXT: .cfi_restore_state
147 ; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
148 ; CHECK-APPLE-NEXT: mov w0, wzr
149 ; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload
150 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 0
151 ; CHECK-APPLE-NEXT: .cfi_restore w30
152 ; CHECK-APPLE-NEXT: .cfi_restore w29
153 ; CHECK-APPLE-NEXT: .cfi_restore w19
154 ; CHECK-APPLE-NEXT: .cfi_restore w20
155 ; CHECK-APPLE-NEXT: ret
156 ; CHECK-APPLE-NEXT: .loh AdrpLdr Lloh2, Lloh3
158 %tobool = icmp eq ptr %p1, null
159 br i1 %tobool, label %return, label %if.end
161 if.end: ; preds = %entry
162 %0 = load i32, ptr @a, align 4, !tbaa !2
163 %conv = sext i32 %0 to i64
164 %1 = inttoptr i64 %conv to ptr
165 %cmp = icmp eq ptr %1, %p1
166 br i1 %cmp, label %if.then2, label %return
168 if.then2: ; preds = %if.end
169 %call = tail call signext i32 @callVoid()
170 %call3 = tail call signext i32 @callNonVoid(ptr nonnull %p1)
173 return: ; preds = %if.end, %entry, %if.then2
174 %retval.0 = phi i32 [ %call3, %if.then2 ], [ 0, %entry ], [ 0, %if.end ]
179 define dso_local ptr @test3(ptr nocapture %p1, i8 zeroext %p2) local_unnamed_addr uwtable {
180 ; CHECK-LABEL: test3:
181 ; CHECK: // %bb.0: // %entry
182 ; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
183 ; CHECK-NEXT: .cfi_def_cfa_offset 32
184 ; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
185 ; CHECK-NEXT: .cfi_offset w19, -8
186 ; CHECK-NEXT: .cfi_offset w20, -16
187 ; CHECK-NEXT: .cfi_offset w30, -32
188 ; CHECK-NEXT: ldr x19, [x0]
189 ; CHECK-NEXT: cbz x19, .LBB2_2
190 ; CHECK-NEXT: // %bb.1: // %land.rhs
191 ; CHECK-NEXT: mov x20, x0
192 ; CHECK-NEXT: mov x0, x19
194 ; CHECK-NEXT: str x0, [x20]
195 ; CHECK-NEXT: .LBB2_2: // %land.end
196 ; CHECK-NEXT: mov x0, x19
197 ; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
198 ; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload
199 ; CHECK-NEXT: .cfi_def_cfa_offset 0
200 ; CHECK-NEXT: .cfi_restore w19
201 ; CHECK-NEXT: .cfi_restore w20
202 ; CHECK-NEXT: .cfi_restore w30
205 ; CHECK-APPLE-LABEL: test3:
206 ; CHECK-APPLE: ; %bb.0: ; %entry
207 ; CHECK-APPLE-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill
208 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 32
209 ; CHECK-APPLE-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill
210 ; CHECK-APPLE-NEXT: .cfi_offset w30, -8
211 ; CHECK-APPLE-NEXT: .cfi_offset w29, -16
212 ; CHECK-APPLE-NEXT: .cfi_offset w19, -24
213 ; CHECK-APPLE-NEXT: .cfi_offset w20, -32
214 ; CHECK-APPLE-NEXT: ldr x19, [x0]
215 ; CHECK-APPLE-NEXT: cbz x19, LBB2_2
216 ; CHECK-APPLE-NEXT: ; %bb.1: ; %land.rhs
217 ; CHECK-APPLE-NEXT: mov x20, x0
218 ; CHECK-APPLE-NEXT: mov x0, x19
219 ; CHECK-APPLE-NEXT: bl _bar
220 ; CHECK-APPLE-NEXT: str x0, [x20]
221 ; CHECK-APPLE-NEXT: LBB2_2: ; %land.end
222 ; CHECK-APPLE-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload
223 ; CHECK-APPLE-NEXT: mov x0, x19
224 ; CHECK-APPLE-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload
225 ; CHECK-APPLE-NEXT: .cfi_def_cfa_offset 0
226 ; CHECK-APPLE-NEXT: .cfi_restore w30
227 ; CHECK-APPLE-NEXT: .cfi_restore w29
228 ; CHECK-APPLE-NEXT: .cfi_restore w19
229 ; CHECK-APPLE-NEXT: .cfi_restore w20
230 ; CHECK-APPLE-NEXT: ret
232 %0 = load ptr, ptr %p1, align 8, !tbaa !6
233 %tobool = icmp eq ptr %0, null
234 br i1 %tobool, label %land.end, label %land.rhs
236 land.rhs: ; preds = %entry
237 %call = tail call ptr @bar(ptr nonnull %0, i8 zeroext %p2)
238 store ptr %call, ptr %p1, align 8, !tbaa !6
241 land.end: ; preds = %entry, %land.rhs
245 declare ptr @bar(ptr, i8 zeroext) local_unnamed_addr
248 !llvm.module.flags = !{!0}
251 !0 = !{i32 1, !"wchar_size", i32 4}
252 !1 = !{!"clang version 10.0.0 (trunk 367381) (llvm/trunk 367388)"}
253 !2 = !{!3, !3, i64 0}
254 !3 = !{!"int", !4, i64 0}
255 !4 = !{!"omnipotent char", !5, i64 0}
256 !5 = !{!"Simple C/C++ TBAA"}
257 !6 = !{!7, !7, i64 0}
258 !7 = !{!"any pointer", !4, i64 0}