1; This test is mainly for the -outliner-leaf-descendants flag for MachineOutliner. 2; 3; ===================== -outliner-leaf-descendants=false ===================== 4; MachineOutliner finds THREE key `OutlinedFunction` and outlines them. They are: 5; ``` 6; mov w0, #1 7; mov w1, #2 8; mov w2, #3 9; mov w3, #4 10; mov w4, #5 11; mov w5, #6 or #7 or #8 12; b 13; ``` 14; Each has: 15; - `SequenceSize=28` and `OccurrenceCount=2` 16; - each Candidate has `CallOverhead=4` and `FrameOverhead=0` 17; - `NotOutlinedCost=28*2=56` and `OutliningCost=4*2+28+0=36` 18; - `Benefit=56-36=20` and `Priority=56/36=1.56` 19; 20; ===================== -outliner-leaf-descendants=true ===================== 21; MachineOutliner finds a FOURTH key `OutlinedFunction`, which is: 22; ``` 23; mov w0, #1 24; mov w1, #2 25; mov w2, #3 26; mov w3, #4 27; mov w4, #5 28; ``` 29; This corresponds to an internal node that has ZERO leaf children, but SIX leaf descendants. 30; It has: 31; - `SequenceSize=20` and `OccurrenceCount=6` 32; - each Candidate has `CallOverhead=12` and `FrameOverhead=4` 33; - `NotOutlinedCost=20*6=120` and `OutliningCost=12*6+20+4=96` 34; - `Benefit=120-96=24` and `Priority=120/96=1.25` 35; 36; The FOURTH `OutlinedFunction` has lower _priority_ compared to the first THREE `OutlinedFunction`. 37; Hence, we use `-outliner-benefit-threshold=22` to check if the FOURTH `OutlinedFunction` is identified. 38 39; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -filetype=obj -o %t 40; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE 41 42; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -outliner-benefit-threshold=22 -filetype=obj -o %t 43; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-NO-CANDIDATE 44 45; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -filetype=obj -o %t 46; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE 47 48; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -outliner-benefit-threshold=22 -filetype=obj -o %t 49; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-LEAF-DESCENDANTS 50 51 52target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" 53target triple = "arm64-apple-macosx14.0.0" 54 55declare i32 @_Z3fooiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) 56 57define i32 @_Z2f1v() minsize { 58 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6) 59 ret i32 %1 60} 61 62define i32 @_Z2f2v() minsize { 63 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6) 64 ret i32 %1 65} 66 67define i32 @_Z2f3v() minsize { 68 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7) 69 ret i32 %1 70} 71 72define i32 @_Z2f4v() minsize { 73 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7) 74 ret i32 %1 75} 76 77define i32 @_Z2f5v() minsize { 78 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8) 79 ret i32 %1 80} 81 82define i32 @_Z2f6v() minsize { 83 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8) 84 ret i32 %1 85} 86 87; CHECK-BASELINE: <_OUTLINED_FUNCTION_0>: 88; CHECK-BASELINE-NEXT: mov w0, #0x1 89; CHECK-BASELINE-NEXT: mov w1, #0x2 90; CHECK-BASELINE-NEXT: mov w2, #0x3 91; CHECK-BASELINE-NEXT: mov w3, #0x4 92; CHECK-BASELINE-NEXT: mov w4, #0x5 93; CHECK-BASELINE-NEXT: mov w5, #0x6 94; CHECK-BASELINE-NEXT: b 95 96; CHECK-BASELINE: <_OUTLINED_FUNCTION_1>: 97; CHECK-BASELINE-NEXT: mov w0, #0x1 98; CHECK-BASELINE-NEXT: mov w1, #0x2 99; CHECK-BASELINE-NEXT: mov w2, #0x3 100; CHECK-BASELINE-NEXT: mov w3, #0x4 101; CHECK-BASELINE-NEXT: mov w4, #0x5 102; CHECK-BASELINE-NEXT: mov w5, #0x8 103; CHECK-BASELINE-NEXT: b 104 105; CHECK-BASELINE: <_OUTLINED_FUNCTION_2>: 106; CHECK-BASELINE-NEXT: mov w0, #0x1 107; CHECK-BASELINE-NEXT: mov w1, #0x2 108; CHECK-BASELINE-NEXT: mov w2, #0x3 109; CHECK-BASELINE-NEXT: mov w3, #0x4 110; CHECK-BASELINE-NEXT: mov w4, #0x5 111; CHECK-BASELINE-NEXT: mov w5, #0x7 112; CHECK-BASELINE-NEXT: b 113 114; CHECK-LEAF-DESCENDANTS: <_OUTLINED_FUNCTION_0>: 115; CHECK-LEAF-DESCENDANTS-NEXT: mov w0, #0x1 116; CHECK-LEAF-DESCENDANTS-NEXT: mov w1, #0x2 117; CHECK-LEAF-DESCENDANTS-NEXT: mov w2, #0x3 118; CHECK-LEAF-DESCENDANTS-NEXT: mov w3, #0x4 119; CHECK-LEAF-DESCENDANTS-NEXT: mov w4, #0x5 120; CHECK-LEAF-DESCENDANTS-NEXT: ret 121 122; CHECK-LEAF-DESCENDANTS-NOT: <_OUTLINED_FUNCTION_1>: 123 124; CHECK-NO-CANDIDATE-NOT: <_OUTLINED_FUNCTION_0>: 125