131 lines · plain
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, #17; mov w1, #28; mov w2, #39; mov w3, #410; mov w4, #511; mov w5, #6 or #7 or #812; b13; ```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, #124; mov w1, #225; mov w2, #326; mov w3, #427; mov w4, #528; ```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 -mattr=+m -mtriple=riscv64 -filetype=obj -o %t40; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE41 42; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -mattr=+m -mtriple=riscv64 -outliner-benefit-threshold=22 -filetype=obj -o %t43; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-NO-CANDIDATE44 45; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -mattr=+m -mtriple=riscv32 -filetype=obj -o %t46; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE47 48; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -mattr=+m -mtriple=riscv32 -outliner-benefit-threshold=22 -filetype=obj -o %t49; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-NO-CANDIDATE50 51; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -mattr=+m -mtriple=riscv64 -filetype=obj -o %t52; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-LEAF-DESCENDANTS53 54; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -mattr=+m -mtriple=riscv64 -outliner-benefit-threshold=22 -filetype=obj -o %t55; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-LEAF-DESCENDANTS56 57 58declare i32 @_Z3fooiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef)59 60define i32 @_Z2f1v() minsize {61 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)62 ret i32 %163}64 65define i32 @_Z2f2v() minsize {66 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)67 ret i32 %168}69 70define i32 @_Z2f3v() minsize {71 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)72 ret i32 %173}74 75define i32 @_Z2f4v() minsize {76 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)77 ret i32 %178}79 80define i32 @_Z2f5v() minsize {81 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)82 ret i32 %183}84 85define i32 @_Z2f6v() minsize {86 %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)87 ret i32 %188}89 90; CHECK-BASELINE: <OUTLINED_FUNCTION_0>:91; CHECK-BASELINE-NEXT: li a0, 0x192; CHECK-BASELINE-NEXT: li a1, 0x293; CHECK-BASELINE-NEXT: li a2, 0x394; CHECK-BASELINE-NEXT: li a3, 0x495; CHECK-BASELINE-NEXT: li a4, 0x596; CHECK-BASELINE-NEXT: li a5, 0x697; CHECK-BASELINE-NEXT: auipc t1, 0x098; CHECK-BASELINE-NEXT: jr t199 100; CHECK-BASELINE: <OUTLINED_FUNCTION_1>:101; CHECK-BASELINE-NEXT: li a0, 0x1102; CHECK-BASELINE-NEXT: li a1, 0x2103; CHECK-BASELINE-NEXT: li a2, 0x3104; CHECK-BASELINE-NEXT: li a3, 0x4105; CHECK-BASELINE-NEXT: li a4, 0x5106; CHECK-BASELINE-NEXT: li a5, 0x8107; CHECK-BASELINE-NEXT: auipc t1, 0x0108; CHECK-BASELINE-NEXT: jr t1109 110; CHECK-BASELINE: <OUTLINED_FUNCTION_2>:111; CHECK-BASELINE-NEXT: li a0, 0x1112; CHECK-BASELINE-NEXT: li a1, 0x2113; CHECK-BASELINE-NEXT: li a2, 0x3114; CHECK-BASELINE-NEXT: li a3, 0x4115; CHECK-BASELINE-NEXT: li a4, 0x5116; CHECK-BASELINE-NEXT: li a5, 0x7117; CHECK-BASELINE-NEXT: auipc t1, 0x0118; CHECK-BASELINE-NEXT: jr t1119 120; CHECK-LEAF-DESCENDANTS: <OUTLINED_FUNCTION_0>:121; CHECK-LEAF-DESCENDANTS-NEXT: li a0, 0x1122; CHECK-LEAF-DESCENDANTS-NEXT: li a1, 0x2123; CHECK-LEAF-DESCENDANTS-NEXT: li a2, 0x3124; CHECK-LEAF-DESCENDANTS-NEXT: li a3, 0x4125; CHECK-LEAF-DESCENDANTS-NEXT: li a4, 0x5126; CHECK-LEAF-DESCENDANTS-NEXT: jr t0127 128; CHECK-LEAF-DESCENDANTS-NOT: <OUTLINED_FUNCTION_1>:129 130; CHECK-NO-CANDIDATE-NOT: <OUTLINED_FUNCTION_0>:131