1 # RUN: llc -mtriple=riscv32 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \
2 # RUN: | FileCheck -check-prefixes=OUTLINED,RV32I-MO %s
3 # RUN: llc -mtriple=riscv64 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \
4 # RUN: | FileCheck -check-prefixes=OUTLINED,RV64I-MO %s
6 # CFIs are invisible (they can be outlined, but won't actually impact the outlining result) if there
7 # is no need to unwind. CFIs will be stripped when we build outlined functions.
10 define void @func1(i32 %a, i32 %b) nounwind { ret void }
12 define void @func2(i32 %a, i32 %b) nounwind { ret void }
14 define void @func3(i32 %a, i32 %b) nounwind { ret void }
18 tracksRegLiveness: true
22 ; RV32I-MO-LABEL: name: func1
23 ; RV32I-MO: liveins: $x10, $x11
24 ; RV32I-MO-NEXT: {{ $}}
25 ; RV32I-MO-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
26 ; RV32I-MO-NEXT: PseudoRET
27 ; RV64I-MO-LABEL: name: func1
28 ; RV64I-MO: liveins: $x10, $x11
29 ; RV64I-MO-NEXT: {{ $}}
30 ; RV64I-MO-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
31 ; RV64I-MO-NEXT: PseudoRET
33 CFI_INSTRUCTION offset $x1, 0
35 CFI_INSTRUCTION offset $x1, -4
37 CFI_INSTRUCTION offset $x1, -8
39 CFI_INSTRUCTION offset $x1, -12
45 tracksRegLiveness: true
49 ; RV32I-MO-LABEL: name: func2
50 ; RV32I-MO: liveins: $x10, $x11
51 ; RV32I-MO-NEXT: {{ $}}
52 ; RV32I-MO-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
53 ; RV32I-MO-NEXT: PseudoRET
54 ; RV64I-MO-LABEL: name: func2
55 ; RV64I-MO: liveins: $x10, $x11
56 ; RV64I-MO-NEXT: {{ $}}
57 ; RV64I-MO-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
58 ; RV64I-MO-NEXT: PseudoRET
60 CFI_INSTRUCTION offset $x1, 0
62 CFI_INSTRUCTION offset $x1, -8
64 CFI_INSTRUCTION offset $x1, -4
66 CFI_INSTRUCTION offset $x1, -12
72 tracksRegLiveness: true
76 ; RV32I-MO-LABEL: name: func3
77 ; RV32I-MO: liveins: $x10, $x11
78 ; RV32I-MO-NEXT: {{ $}}
79 ; RV32I-MO-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
80 ; RV32I-MO-NEXT: PseudoRET
81 ; RV64I-MO-LABEL: name: func3
82 ; RV64I-MO: liveins: $x10, $x11
83 ; RV64I-MO-NEXT: {{ $}}
84 ; RV64I-MO-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
85 ; RV64I-MO-NEXT: PseudoRET
87 CFI_INSTRUCTION offset $x1, -12
89 CFI_INSTRUCTION offset $x1, -8
91 CFI_INSTRUCTION offset $x1, -4
93 CFI_INSTRUCTION offset $x1, 0
98 # OUTLINED-LABEL: name: OUTLINED_FUNCTION_0
99 # OUTLINED: liveins: $x11, $x10, $x5
100 # OUTLINED-NEXT: {{ $}}
101 # OUTLINED-NEXT: $x10 = ORI $x10, 1023
102 # OUTLINED-NEXT: $x11 = ORI $x11, 1023
103 # OUTLINED-NEXT: $x12 = ADDI $x10, 17
104 # OUTLINED-NEXT: $x11 = AND $x12, $x11
105 # OUTLINED-NEXT: $x10 = SUB $x10, $x11
106 # OUTLINED-NEXT: $x0 = JALR $x5, 0