|
| 1 | +# RUN: llc -mtriple=aarch64--- -run-pass=machine-outliner -machine-outline-runs=2 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix TWO-RUNS |
| 2 | +# RUN: llc -mtriple=aarch64--- -run-pass=machine-outliner -machine-outline-runs=1 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix ONE-RUN |
| 3 | +# RUN: llc -mtriple=aarch64--- -run-pass=machine-outliner -machine-outline-runs=4 -verify-machineinstrs %s -o - | FileCheck %s --check-prefix FOUR-RUNS |
| 4 | + |
| 5 | +# Example of Repeated Instruction Sequence - Iterative Machine Outlining |
| 6 | +# |
| 7 | +#; define void @"$s12"(...) { define i64 @"$s5” (...) { define void @"$s13"(...) { |
| 8 | +# ... ... ... |
| 9 | +# %8 = load i1, i1* %7 %8 = load i1, i1* %7 |
| 10 | +# %9 = load i4, i4*, %6 %9 = load i4, i4*, %6 %9 = load i4, i4*, %6 |
| 11 | +# store i4 %9, i4* %5 store i4 %9, i4* %5 store i4 %9, i4* %5 |
| 12 | +# ... ... ... |
| 13 | +# } } } |
| 14 | +# |
| 15 | +# After machine outliner (1st time) |
| 16 | +# |
| 17 | +# define void @"$s12"(...) { define i64 @"$s5” (...) { define void @"$s13"(...) { |
| 18 | +# ... ... ... |
| 19 | +# %8 = load i1, i1* %7 %8 = load i1, i1* %7 |
| 20 | +# call void @outlined_function_1_1 call void @outlined_function_1_1 call void @outlined_function_1_1 |
| 21 | +# ... ... ... |
| 22 | +# } } } |
| 23 | +# |
| 24 | +# After machine outliner (2nd time) |
| 25 | +# |
| 26 | +# define void @"$s12"(...) { define i64 @"$s5” (...) { define void @"$s13"(...) { |
| 27 | +# ... ... ... |
| 28 | +# call void @outlined_function_2_1 call void @outlined_function_1_1 call void @outlined_function_2_1 |
| 29 | +# ... ... ... |
| 30 | +# } } } |
| 31 | +# |
| 32 | +# Check whether machine outliner can further find the outlining opportunity after machine |
| 33 | +# outlining has performed. |
| 34 | +# |
| 35 | +--- | |
| 36 | + target triple = "aarch64-apple-darwin" |
| 37 | + |
| 38 | + declare void @foo() local_unnamed_addr |
| 39 | + |
| 40 | + declare void @widget() local_unnamed_addr |
| 41 | + |
| 42 | + ; Function Attrs: minsize noredzone optsize |
| 43 | + define void @baz.14() #0 { |
| 44 | + ret void |
| 45 | + } |
| 46 | + |
| 47 | + ; Function Attrs: minsize noredzone optsize |
| 48 | + define void @baz.15() #0 { |
| 49 | + ret void |
| 50 | + } |
| 51 | + |
| 52 | + ; Function Attrs: minsize noredzone optsize |
| 53 | + define void @baz.16() #0 { |
| 54 | + ret void |
| 55 | + } |
| 56 | + |
| 57 | + attributes #0 = { minsize noredzone optsize } |
| 58 | +... |
| 59 | +--- |
| 60 | +name: baz.14 |
| 61 | +tracksRegLiveness: true |
| 62 | +stack: |
| 63 | + - { id: 0, offset: -8, size: 8 } |
| 64 | + - { id: 1, offset: -16, size: 8 } |
| 65 | +body: | |
| 66 | + bb.0: |
| 67 | + liveins: $x0, $x19, $lr |
| 68 | +
|
| 69 | + early-clobber $sp = frame-setup STPXpre killed $lr, killed $x19, $sp, -2 :: (store 8 into %stack.1), (store 8 into %stack.0) |
| 70 | + frame-setup CFI_INSTRUCTION def_cfa_offset 16 |
| 71 | + frame-setup CFI_INSTRUCTION offset $w19, -8 |
| 72 | + frame-setup CFI_INSTRUCTION offset $w30, -16 |
| 73 | + renamable $x19 = COPY $x0 |
| 74 | + renamable $x0 = nuw ADDXri $x0, 48, 0 |
| 75 | + $x1 = ADDXri $sp, 0, 0 |
| 76 | + dead $w2 = MOVi32imm 33, implicit-def $x2 |
| 77 | + $x3 = COPY $xzr |
| 78 | + BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit killed $x1, implicit killed $x2, implicit killed $x3, implicit-def $sp |
| 79 | + $x0 = COPY killed renamable $x19 |
| 80 | + BL @widget, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp |
| 81 | + early-clobber $sp, $lr, $x19 = frame-destroy LDPXpost $sp, 2 :: (load 8 from %stack.1), (load 8 from %stack.0) |
| 82 | + RET_ReallyLR |
| 83 | +
|
| 84 | +... |
| 85 | +--- |
| 86 | +name: baz.15 |
| 87 | +stack: |
| 88 | + - { id: 0, offset: -8, size: 8 } |
| 89 | + - { id: 1, offset: -16, size: 8 } |
| 90 | +body: | |
| 91 | + bb.0: |
| 92 | + early-clobber $sp = frame-setup STPXpre killed $lr, killed $x19, $sp, -2 :: (store 8 into %stack.1), (store 8 into %stack.0) |
| 93 | + frame-setup CFI_INSTRUCTION def_cfa_offset 16 |
| 94 | + frame-setup CFI_INSTRUCTION offset $w19, -8 |
| 95 | + frame-setup CFI_INSTRUCTION offset $w30, -16 |
| 96 | + renamable $x19 = COPY $x0 |
| 97 | + renamable $x0 = nuw ADDXri killed renamable $x1, 16, 0 |
| 98 | + $x1 = ADDXri $sp, 0, 0 |
| 99 | + dead $w2 = MOVi32imm 33, implicit-def $x2 |
| 100 | + $x3 = COPY $xzr |
| 101 | + BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit $x1, implicit killed $x2, implicit killed $x3, implicit-def $sp |
| 102 | + $x0 = COPY killed renamable $x19 |
| 103 | + BL @widget, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp |
| 104 | + early-clobber $sp, $lr, $x19 = frame-destroy LDPXpost $sp, 2 :: (load 8 from %stack.1), (load 8 from %stack.0) |
| 105 | + RET_ReallyLR |
| 106 | +
|
| 107 | +... |
| 108 | +--- |
| 109 | +name: baz.16 |
| 110 | +tracksRegLiveness: true |
| 111 | +stack: |
| 112 | + - { id: 0, offset: -8, size: 8 } |
| 113 | + - { id: 1, offset: -16, size: 8 } |
| 114 | +body: | |
| 115 | + bb.0: |
| 116 | + liveins: $x0, $x19, $lr |
| 117 | +
|
| 118 | + early-clobber $sp = frame-setup STPXpre killed $lr, killed $x19, $sp, -2 :: (store 8 into %stack.1), (store 8 into %stack.0) |
| 119 | + frame-setup CFI_INSTRUCTION def_cfa_offset 16 |
| 120 | + frame-setup CFI_INSTRUCTION offset $w19, -8 |
| 121 | + frame-setup CFI_INSTRUCTION offset $w30, -16 |
| 122 | + renamable $x19 = COPY $x0 |
| 123 | + renamable $x0 = nuw ADDXri $x0, 48, 0 |
| 124 | + $x1 = ADDXri $sp, 0, 0 |
| 125 | + dead $w2 = MOVi32imm 33, implicit-def $x2 |
| 126 | + $x3 = COPY $xzr |
| 127 | + BL @foo, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit killed $x1, implicit killed $x2, implicit killed $x3, implicit-def $sp |
| 128 | + $x0 = COPY killed renamable $x19 |
| 129 | + BL @widget, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp |
| 130 | + early-clobber $sp, $lr, $x19 = frame-destroy LDPXpost $sp, 2 :: (load 8 from %stack.1), (load 8 from %stack.0) |
| 131 | + RET_ReallyLR |
| 132 | +
|
| 133 | +... |
| 134 | + |
| 135 | +# TWO-RUNS: name: OUTLINED_FUNCTION_2_0 |
| 136 | +# TWO-RUNS-DAG: bb.0: |
| 137 | +# TWO-RUNS-DAG: renamable $x19 = COPY $x0 |
| 138 | +# TWO-RUNS-NEXT: renamable $x0 = nuw ADDXri $x0, 48, 0 |
| 139 | +# TWO-RUNS-NEXT: TCRETURNdi @OUTLINED_FUNCTION_0, 0, implicit $sp |
| 140 | +# |
| 141 | +# The machine outliner is expected to stop at the 1st iteration for case ONE-RUN |
| 142 | +# since machine-outline-runs is specified as 1. |
| 143 | +# ONE-RUN-NOT: [[OUTLINED:OUTLINED_FUNCTION_2_[0-9]+]] |
| 144 | +# |
| 145 | +# The machine outliner is expected to stop at the 3rd iteration for case FOUR-RUNS |
| 146 | +# since the MIR has no change at the 3rd iteration. |
| 147 | +# FOUR-RUNS-NOT: [[OUTLINED:OUTLINED_FUNCTION_3_[0-9]+]] |
| 148 | +# FOUR-RUNS-NOT: [[OUTLINED:OUTLINED_FUNCTION_4_[0-9]+]] |
0 commit comments