|
| 1 | +# RUN: llc -march=riscv32 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \ |
| 2 | +# RUN: | FileCheck -check-prefixes=OUTLINED,RV32I-MO %s |
| 3 | +# RUN: llc -march=riscv64 -x mir -run-pass=machine-outliner -simplify-mir -verify-machineinstrs < %s \ |
| 4 | +# RUN: | FileCheck -check-prefixes=OUTLINED,RV64I-MO %s |
| 5 | + |
| 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. |
| 8 | + |
| 9 | +--- | |
| 10 | + define void @func1(i32 %a, i32 %b) nounwind { ret void } |
| 11 | + |
| 12 | + define void @func2(i32 %a, i32 %b) nounwind { ret void } |
| 13 | + |
| 14 | + define void @func3(i32 %a, i32 %b) nounwind { ret void } |
| 15 | +... |
| 16 | +--- |
| 17 | +name: func1 |
| 18 | +tracksRegLiveness: true |
| 19 | +body: | |
| 20 | + bb.0: |
| 21 | + liveins: $x10, $x11 |
| 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 |
| 32 | + $x10 = ORI $x10, 1023 |
| 33 | + CFI_INSTRUCTION offset $x1, 0 |
| 34 | + $x11 = ORI $x11, 1023 |
| 35 | + CFI_INSTRUCTION offset $x1, -4 |
| 36 | + $x12 = ADDI $x10, 17 |
| 37 | + CFI_INSTRUCTION offset $x1, -8 |
| 38 | + $x11 = AND $x12, $x11 |
| 39 | + CFI_INSTRUCTION offset $x1, -12 |
| 40 | + $x10 = SUB $x10, $x11 |
| 41 | + PseudoRET |
| 42 | +... |
| 43 | +--- |
| 44 | +name: func2 |
| 45 | +tracksRegLiveness: true |
| 46 | +body: | |
| 47 | + bb.0: |
| 48 | + liveins: $x10, $x11 |
| 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 |
| 59 | + $x10 = ORI $x10, 1023 |
| 60 | + CFI_INSTRUCTION offset $x1, 0 |
| 61 | + $x11 = ORI $x11, 1023 |
| 62 | + CFI_INSTRUCTION offset $x1, -8 |
| 63 | + $x12 = ADDI $x10, 17 |
| 64 | + CFI_INSTRUCTION offset $x1, -4 |
| 65 | + $x11 = AND $x12, $x11 |
| 66 | + CFI_INSTRUCTION offset $x1, -12 |
| 67 | + $x10 = SUB $x10, $x11 |
| 68 | + PseudoRET |
| 69 | +... |
| 70 | +--- |
| 71 | +name: func3 |
| 72 | +tracksRegLiveness: true |
| 73 | +body: | |
| 74 | + bb.0: |
| 75 | + liveins: $x10, $x11 |
| 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 |
| 86 | + $x10 = ORI $x10, 1023 |
| 87 | + CFI_INSTRUCTION offset $x1, -12 |
| 88 | + $x11 = ORI $x11, 1023 |
| 89 | + CFI_INSTRUCTION offset $x1, -8 |
| 90 | + $x12 = ADDI $x10, 17 |
| 91 | + CFI_INSTRUCTION offset $x1, -4 |
| 92 | + $x11 = AND $x12, $x11 |
| 93 | + CFI_INSTRUCTION offset $x1, 0 |
| 94 | + $x10 = SUB $x10, $x11 |
| 95 | + PseudoRET |
| 96 | +
|
| 97 | +
|
| 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 |
0 commit comments