1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=riscv32 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs -outliner-leaf-descendants=false < %s \
4 # RUN: llc -mtriple=riscv64 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs -outliner-leaf-descendants=false < %s \
6 # RUN: llc -mtriple=riscv32 -x mir -run-pass=machine-outliner -simplify-mir --function-sections -verify-machineinstrs -outliner-leaf-descendants=false < %s \
7 # RUN: | FileCheck -check-prefix=CHECK-FS %s
8 # RUN: llc -mtriple=riscv64 -x mir -run-pass=machine-outliner -simplify-mir --function-sections -verify-machineinstrs -outliner-leaf-descendants=false < %s \
9 # RUN: | FileCheck -check-prefix=CHECK-FS %s
12 ; Cannot outline instructions with pcrel-lo operands if function section
14 @bar = dso_local local_unnamed_addr global i32 0, align 4
15 define i32 @foo(i32 %a, i32 %b) { ret i32 0 }
18 define i32 @foo2(i32 %a, i32 %b) comdat { ret i32 0 }
20 define i32 @foo3(i32 %a, i32 %b) section ".abc" { ret i32 0 }
22 define i32 @foo4(i32 %a, i32 %b) !section_prefix !0 { ret i32 0 }
23 !0 = !{!"function_section_prefix", !"myprefix"}
27 tracksRegLiveness: true
29 ; CHECK-LABEL: name: foo
31 ; CHECK-NEXT: liveins: $x10, $x11, $x13
33 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_1, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11, implicit $x13
34 ; CHECK-NEXT: PseudoBR %bb.3
37 ; CHECK-NEXT: liveins: $x10, $x11, $x13
39 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_1, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11, implicit $x13
40 ; CHECK-NEXT: PseudoBR %bb.3
43 ; CHECK-NEXT: liveins: $x10, $x11, $x13
45 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_1, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11, implicit $x13
46 ; CHECK-NEXT: PseudoBR %bb.3
49 ; CHECK-NEXT: PseudoRET
51 ; CHECK-FS-LABEL: name: foo
53 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
54 ; CHECK-FS-NEXT: {{ $}}
55 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
56 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
57 ; CHECK-FS-NEXT: PseudoBR %bb.3
58 ; CHECK-FS-NEXT: {{ $}}
59 ; CHECK-FS-NEXT: bb.1:
60 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
61 ; CHECK-FS-NEXT: {{ $}}
62 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
63 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
64 ; CHECK-FS-NEXT: PseudoBR %bb.3
65 ; CHECK-FS-NEXT: {{ $}}
66 ; CHECK-FS-NEXT: bb.2:
67 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
68 ; CHECK-FS-NEXT: {{ $}}
69 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
70 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
71 ; CHECK-FS-NEXT: PseudoBR %bb.3
72 ; CHECK-FS-NEXT: {{ $}}
73 ; CHECK-FS-NEXT: bb.3:
74 ; CHECK-FS-NEXT: PseudoRET
76 liveins: $x10, $x11, $x13
82 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
86 liveins: $x10, $x11, $x13
92 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
96 liveins: $x10, $x11, $x13
100 $x11 = AND $x12, $x11
101 $x10 = SUB $x10, $x11
102 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
110 tracksRegLiveness: true
112 ; CHECK-LABEL: name: foo2
114 ; CHECK-NEXT: liveins: $x10, $x11, $x13
116 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
117 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
118 ; CHECK-NEXT: PseudoBR %bb.3
121 ; CHECK-NEXT: liveins: $x10, $x11, $x13
123 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
124 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
125 ; CHECK-NEXT: PseudoBR %bb.3
128 ; CHECK-NEXT: liveins: $x10, $x11, $x13
130 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
131 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
132 ; CHECK-NEXT: PseudoBR %bb.3
135 ; CHECK-NEXT: PseudoRET
137 ; CHECK-FS-LABEL: name: foo2
139 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
140 ; CHECK-FS-NEXT: {{ $}}
141 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
142 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
143 ; CHECK-FS-NEXT: PseudoBR %bb.3
144 ; CHECK-FS-NEXT: {{ $}}
145 ; CHECK-FS-NEXT: bb.1:
146 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
147 ; CHECK-FS-NEXT: {{ $}}
148 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
149 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
150 ; CHECK-FS-NEXT: PseudoBR %bb.3
151 ; CHECK-FS-NEXT: {{ $}}
152 ; CHECK-FS-NEXT: bb.2:
153 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
154 ; CHECK-FS-NEXT: {{ $}}
155 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
156 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
157 ; CHECK-FS-NEXT: PseudoBR %bb.3
158 ; CHECK-FS-NEXT: {{ $}}
159 ; CHECK-FS-NEXT: bb.3:
160 ; CHECK-FS-NEXT: PseudoRET
162 liveins: $x10, $x11, $x13
164 $x11 = ORI $x11, 1023
166 $x11 = AND $x12, $x11
167 $x10 = SUB $x10, $x11
168 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
172 liveins: $x10, $x11, $x13
174 $x11 = ORI $x11, 1023
176 $x11 = AND $x12, $x11
177 $x10 = SUB $x10, $x11
178 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
182 liveins: $x10, $x11, $x13
184 $x11 = ORI $x11, 1023
186 $x11 = AND $x12, $x11
187 $x10 = SUB $x10, $x11
188 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
196 tracksRegLiveness: true
198 ; CHECK-LABEL: name: foo3
200 ; CHECK-NEXT: liveins: $x10, $x11, $x13
202 ; CHECK-NEXT: $x11 = ORI $x11, 1023
203 ; CHECK-NEXT: $x12 = ADDI $x10, 17
204 ; CHECK-NEXT: $x11 = AND $x12, $x11
205 ; CHECK-NEXT: $x10 = SUB $x10, $x11
206 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
207 ; CHECK-NEXT: PseudoBR %bb.3
210 ; CHECK-NEXT: liveins: $x10, $x11, $x13
212 ; CHECK-NEXT: $x11 = ORI $x11, 1023
213 ; CHECK-NEXT: $x12 = ADDI $x10, 17
214 ; CHECK-NEXT: $x11 = AND $x12, $x11
215 ; CHECK-NEXT: $x10 = SUB $x10, $x11
216 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
217 ; CHECK-NEXT: PseudoBR %bb.3
220 ; CHECK-NEXT: liveins: $x10, $x11, $x13
222 ; CHECK-NEXT: $x11 = ORI $x11, 1023
223 ; CHECK-NEXT: $x12 = ADDI $x10, 17
224 ; CHECK-NEXT: $x11 = AND $x12, $x11
225 ; CHECK-NEXT: $x10 = SUB $x10, $x11
226 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
227 ; CHECK-NEXT: PseudoBR %bb.3
230 ; CHECK-NEXT: PseudoRET
232 ; CHECK-FS-LABEL: name: foo3
234 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
235 ; CHECK-FS-NEXT: {{ $}}
236 ; CHECK-FS-NEXT: $x11 = ORI $x11, 1023
237 ; CHECK-FS-NEXT: $x12 = ADDI $x10, 17
238 ; CHECK-FS-NEXT: $x11 = AND $x12, $x11
239 ; CHECK-FS-NEXT: $x10 = SUB $x10, $x11
240 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
241 ; CHECK-FS-NEXT: PseudoBR %bb.3
242 ; CHECK-FS-NEXT: {{ $}}
243 ; CHECK-FS-NEXT: bb.1:
244 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
245 ; CHECK-FS-NEXT: {{ $}}
246 ; CHECK-FS-NEXT: $x11 = ORI $x11, 1023
247 ; CHECK-FS-NEXT: $x12 = ADDI $x10, 17
248 ; CHECK-FS-NEXT: $x11 = AND $x12, $x11
249 ; CHECK-FS-NEXT: $x10 = SUB $x10, $x11
250 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
251 ; CHECK-FS-NEXT: PseudoBR %bb.3
252 ; CHECK-FS-NEXT: {{ $}}
253 ; CHECK-FS-NEXT: bb.2:
254 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
255 ; CHECK-FS-NEXT: {{ $}}
256 ; CHECK-FS-NEXT: $x11 = ORI $x11, 1023
257 ; CHECK-FS-NEXT: $x12 = ADDI $x10, 17
258 ; CHECK-FS-NEXT: $x11 = AND $x12, $x11
259 ; CHECK-FS-NEXT: $x10 = SUB $x10, $x11
260 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
261 ; CHECK-FS-NEXT: PseudoBR %bb.3
262 ; CHECK-FS-NEXT: {{ $}}
263 ; CHECK-FS-NEXT: bb.3:
264 ; CHECK-FS-NEXT: PseudoRET
266 liveins: $x10, $x11, $x13
268 $x11 = ORI $x11, 1023
270 $x11 = AND $x12, $x11
271 $x10 = SUB $x10, $x11
272 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
276 liveins: $x10, $x11, $x13
278 $x11 = ORI $x11, 1023
280 $x11 = AND $x12, $x11
281 $x10 = SUB $x10, $x11
282 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
286 liveins: $x10, $x11, $x13
288 $x11 = ORI $x11, 1023
290 $x11 = AND $x12, $x11
291 $x10 = SUB $x10, $x11
292 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
300 tracksRegLiveness: true
302 ; CHECK-LABEL: name: foo4
304 ; CHECK-NEXT: liveins: $x10, $x11, $x13
306 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
307 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
308 ; CHECK-NEXT: PseudoBR %bb.3
311 ; CHECK-NEXT: liveins: $x10, $x11, $x13
313 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
314 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
315 ; CHECK-NEXT: PseudoBR %bb.3
318 ; CHECK-NEXT: liveins: $x10, $x11, $x13
320 ; CHECK-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
321 ; CHECK-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
322 ; CHECK-NEXT: PseudoBR %bb.3
325 ; CHECK-NEXT: PseudoRET
327 ; CHECK-FS-LABEL: name: foo4
329 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
330 ; CHECK-FS-NEXT: {{ $}}
331 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
332 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
333 ; CHECK-FS-NEXT: PseudoBR %bb.3
334 ; CHECK-FS-NEXT: {{ $}}
335 ; CHECK-FS-NEXT: bb.1:
336 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
337 ; CHECK-FS-NEXT: {{ $}}
338 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
339 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
340 ; CHECK-FS-NEXT: PseudoBR %bb.3
341 ; CHECK-FS-NEXT: {{ $}}
342 ; CHECK-FS-NEXT: bb.2:
343 ; CHECK-FS-NEXT: liveins: $x10, $x11, $x13
344 ; CHECK-FS-NEXT: {{ $}}
345 ; CHECK-FS-NEXT: $x5 = PseudoCALLReg target-flags(riscv-call) @OUTLINED_FUNCTION_0, implicit-def $x5, implicit-def $x10, implicit-def $x11, implicit-def $x12, implicit $x10, implicit $x11
346 ; CHECK-FS-NEXT: $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
347 ; CHECK-FS-NEXT: PseudoBR %bb.3
348 ; CHECK-FS-NEXT: {{ $}}
349 ; CHECK-FS-NEXT: bb.3:
350 ; CHECK-FS-NEXT: PseudoRET
352 liveins: $x10, $x11, $x13
354 $x11 = ORI $x11, 1023
356 $x11 = AND $x12, $x11
357 $x10 = SUB $x10, $x11
358 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
362 liveins: $x10, $x11, $x13
364 $x11 = ORI $x11, 1023
366 $x11 = AND $x12, $x11
367 $x10 = SUB $x10, $x11
368 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)
372 liveins: $x10, $x11, $x13
374 $x11 = ORI $x11, 1023
376 $x11 = AND $x12, $x11
377 $x10 = SUB $x10, $x11
378 $x11 = LW killed renamable $x13, target-flags(riscv-pcrel-lo) <mcsymbol .Lpcrel_hi1> :: (dereferenceable load (s32) from @bar)