1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc -run-pass=cfi-fixup %s -o - | FileCheck %s
4 source_filename = "cfi-fixup.ll"
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 target triple = "aarch64-linux"
8 define i32 @f(i32 %x) #0 {
10 %p = alloca i8, i32 30000, align 1
11 switch i32 %x, label %if.end7 [
13 i32 1, label %if.then2
14 i32 2, label %if.then5
17 if.then2: ; preds = %entry
18 %call = tail call i32 @g1(i32 1)
19 %add = add nsw i32 %call, 1
22 if.then5: ; preds = %entry
23 %call6 = tail call i32 @g0(i32 2)
24 %sub = sub nsw i32 1, %call6
27 if.end7: ; preds = %entry
30 return: ; preds = %if.end7, %if.then5, %if.then2, %entry
31 %retval.0 = phi i32 [ %add, %if.then2 ], [ %sub, %if.then5 ], [ 0, %if.end7 ], [ 1, %entry ]
39 attributes #0 = { uwtable "probe-stack"="inline-asm" }
45 exposesReturnsTwice: false
47 regBankSelected: false
50 tracksRegLiveness: true
53 callsUnwindInit: false
59 failsVerification: false
60 tracksDebugUserValues: true
63 - { reg: '$w0', virtual-reg: '' }
65 isFrameAddressTaken: false
66 isReturnAddressTaken: false
77 cvBytesOfCalleeSavedRegisters: 0
78 hasOpaqueSPAdjustment: false
80 hasMustTailInVarArgFunc: false
87 - { id: 0, name: p, type: default, offset: -30016, size: 30000, alignment: 1,
88 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
89 local-offset: -30000, debug-info-variable: '', debug-info-expression: '',
90 debug-info-location: '' }
91 - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
92 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
93 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
94 - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
95 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true,
96 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
99 debugValueSubstitutions: []
104 ; CHECK-LABEL: name: f
106 ; CHECK-NEXT: successors: %bb.1(0x80000000)
107 ; CHECK-NEXT: liveins: $w0, $lr, $fp
109 ; CHECK-NEXT: early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -2 :: (store (s64) into %stack.2), (store (s64) into %stack.1)
110 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
111 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w30, -8
112 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION offset $w29, -16
113 ; CHECK-NEXT: $x9 = frame-setup SUBXri $sp, 7, 12
114 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa $w9, 28688
116 ; CHECK-NEXT: bb.1.entry:
117 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.1(0x40000000)
118 ; CHECK-NEXT: liveins: $x9
120 ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 1, 12
121 ; CHECK-NEXT: $xzr = frame-setup SUBSXrx64 $sp, $x9, 24, implicit-def $nzcv
122 ; CHECK-NEXT: frame-setup STRXui $xzr, $sp, 0
123 ; CHECK-NEXT: frame-setup Bcc 1, %bb.1, implicit killed $nzcv
125 ; CHECK-NEXT: bb.2.entry:
126 ; CHECK-NEXT: successors: %bb.6(0x20000000), %bb.3(0x60000000)
127 ; CHECK-NEXT: liveins: $w0
129 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_register $wsp
130 ; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 1328, 0
131 ; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 30016
132 ; CHECK-NEXT: CFI_INSTRUCTION remember_state
133 ; CHECK-NEXT: frame-setup STRXui $xzr, $sp, 0
134 ; CHECK-NEXT: CBZW renamable $w0, %bb.6
136 ; CHECK-NEXT: bb.3.entry:
137 ; CHECK-NEXT: successors: %bb.7(0x2aaaaaab), %bb.4(0x55555555)
138 ; CHECK-NEXT: liveins: $w0
140 ; CHECK-NEXT: dead $wzr = SUBSWri renamable $w0, 2, 0, implicit-def $nzcv
141 ; CHECK-NEXT: Bcc 0, %bb.7, implicit killed $nzcv
143 ; CHECK-NEXT: bb.4.entry:
144 ; CHECK-NEXT: successors: %bb.5(0x40000000), %bb.8(0x40000000)
145 ; CHECK-NEXT: liveins: $w0
147 ; CHECK-NEXT: dead $wzr = SUBSWri renamable $w0, 1, 0, implicit-def $nzcv
148 ; CHECK-NEXT: Bcc 1, %bb.8, implicit killed $nzcv
150 ; CHECK-NEXT: bb.5.if.then2:
151 ; CHECK-NEXT: liveins: $w0
153 ; CHECK-NEXT: BL @g1, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
154 ; CHECK-NEXT: renamable $w0 = nsw ADDWri killed renamable $w0, 1, 0
155 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 7, 12
156 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
157 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1328, 0
158 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16
159 ; CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
160 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0
161 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w30
162 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w29
163 ; CHECK-NEXT: RET undef $lr, implicit killed $w0
166 ; CHECK-NEXT: CFI_INSTRUCTION restore_state
167 ; CHECK-NEXT: CFI_INSTRUCTION remember_state
168 ; CHECK-NEXT: renamable $w0 = MOVZWi 1, 0
169 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 7, 12
170 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
171 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1328, 0
172 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16
173 ; CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
174 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0
175 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w30
176 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w29
177 ; CHECK-NEXT: RET undef $lr, implicit killed $w0
179 ; CHECK-NEXT: bb.7.if.then5:
180 ; CHECK-NEXT: liveins: $w0
182 ; CHECK-NEXT: CFI_INSTRUCTION restore_state
183 ; CHECK-NEXT: CFI_INSTRUCTION remember_state
184 ; CHECK-NEXT: BL @g0, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
185 ; CHECK-NEXT: renamable $w8 = MOVZWi 1, 0
186 ; CHECK-NEXT: $w0 = SUBWrs killed renamable $w8, killed renamable $w0, 0
187 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 7, 12
188 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
189 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1328, 0
190 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16
191 ; CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
192 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0
193 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w30
194 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w29
195 ; CHECK-NEXT: RET undef $lr, implicit killed $w0
197 ; CHECK-NEXT: bb.8.if.end7:
198 ; CHECK-NEXT: CFI_INSTRUCTION restore_state
199 ; CHECK-NEXT: $w0 = ORRWrs $wzr, $wzr, 0
200 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 7, 12
201 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
202 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 1328, 0
203 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 16
204 ; CHECK-NEXT: early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
205 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0
206 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w30
207 ; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $w29
208 ; CHECK-NEXT: RET undef $lr, implicit killed $w0
210 successors: %bb.1(0x80000000)
211 liveins: $w0, $lr, $fp
213 early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -2 :: (store (s64) into %stack.2), (store (s64) into %stack.1)
214 frame-setup CFI_INSTRUCTION def_cfa_offset 16
215 frame-setup CFI_INSTRUCTION offset $w30, -8
216 frame-setup CFI_INSTRUCTION offset $w29, -16
217 $x9 = frame-setup SUBXri $sp, 7, 12
218 frame-setup CFI_INSTRUCTION def_cfa $w9, 28688
221 successors: %bb.2(0x40000000), %bb.1(0x40000000)
224 $sp = frame-setup SUBXri $sp, 1, 12
225 $xzr = frame-setup SUBSXrx64 $sp, $x9, 24, implicit-def $nzcv
226 frame-setup STRXui $xzr, $sp, 0
227 frame-setup Bcc 1, %bb.1, implicit killed $nzcv
230 successors: %bb.6(0x20000000), %bb.3(0x60000000)
233 frame-setup CFI_INSTRUCTION def_cfa_register $wsp
234 $sp = frame-setup SUBXri $sp, 1328, 0
235 frame-setup CFI_INSTRUCTION def_cfa_offset 30016
236 frame-setup STRXui $xzr, $sp, 0
237 CBZW renamable $w0, %bb.6
240 successors: %bb.7(0x2aaaaaab), %bb.4(0x55555555)
243 dead $wzr = SUBSWri renamable $w0, 2, 0, implicit-def $nzcv
244 Bcc 0, %bb.7, implicit killed $nzcv
247 successors: %bb.5(0x40000000), %bb.8(0x40000000)
250 dead $wzr = SUBSWri renamable $w0, 1, 0, implicit-def $nzcv
251 Bcc 1, %bb.8, implicit killed $nzcv
256 BL @g1, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
257 renamable $w0 = nsw ADDWri killed renamable $w0, 1, 0
258 $sp = frame-destroy ADDXri $sp, 7, 12
259 frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
260 $sp = frame-destroy ADDXri $sp, 1328, 0
261 frame-destroy CFI_INSTRUCTION def_cfa_offset 16
262 early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
263 frame-destroy CFI_INSTRUCTION def_cfa_offset 0
264 frame-destroy CFI_INSTRUCTION restore $w30
265 frame-destroy CFI_INSTRUCTION restore $w29
266 RET undef $lr, implicit killed $w0
269 renamable $w0 = MOVZWi 1, 0
270 $sp = frame-destroy ADDXri $sp, 7, 12
271 frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
272 $sp = frame-destroy ADDXri $sp, 1328, 0
273 frame-destroy CFI_INSTRUCTION def_cfa_offset 16
274 early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
275 frame-destroy CFI_INSTRUCTION def_cfa_offset 0
276 frame-destroy CFI_INSTRUCTION restore $w30
277 frame-destroy CFI_INSTRUCTION restore $w29
278 RET undef $lr, implicit killed $w0
283 BL @g0, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $w0, implicit-def $sp, implicit-def $w0
284 renamable $w8 = MOVZWi 1, 0
285 $w0 = SUBWrs killed renamable $w8, killed renamable $w0, 0
286 $sp = frame-destroy ADDXri $sp, 7, 12
287 frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
288 $sp = frame-destroy ADDXri $sp, 1328, 0
289 frame-destroy CFI_INSTRUCTION def_cfa_offset 16
290 early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
291 frame-destroy CFI_INSTRUCTION def_cfa_offset 0
292 frame-destroy CFI_INSTRUCTION restore $w30
293 frame-destroy CFI_INSTRUCTION restore $w29
294 RET undef $lr, implicit killed $w0
297 $w0 = ORRWrs $wzr, $wzr, 0
298 $sp = frame-destroy ADDXri $sp, 7, 12
299 frame-destroy CFI_INSTRUCTION def_cfa_offset 1344
300 $sp = frame-destroy ADDXri $sp, 1328, 0
301 frame-destroy CFI_INSTRUCTION def_cfa_offset 16
302 early-clobber $sp, $fp, $lr = frame-destroy LDPXpost $sp, 2 :: (load (s64) from %stack.2), (load (s64) from %stack.1)
303 frame-destroy CFI_INSTRUCTION def_cfa_offset 0
304 frame-destroy CFI_INSTRUCTION restore $w30
305 frame-destroy CFI_INSTRUCTION restore $w29
306 RET undef $lr, implicit killed $w0