@@ -888,16 +888,20 @@ struct MachineOutliner : public ModulePass {
888
888
// / \param FunctionList A list of functions to be inserted into the module.
889
889
// / \param Mapper Contains the instruction mappings for the module.
890
890
bool outline (Module &M, std::vector<OutlinedFunction> &FunctionList,
891
- InstructionMapper &Mapper);
891
+ InstructionMapper &Mapper,
892
+ unsigned &OutlinedFunctionNum);
892
893
893
894
// / Creates a function for \p OF and inserts it into the module.
894
895
MachineFunction *createOutlinedFunction (Module &M, OutlinedFunction &OF,
895
896
InstructionMapper &Mapper,
896
897
unsigned Name);
897
898
899
+ // / Calls 'doOutline()'.
900
+ bool runOnModule (Module &M) override ;
901
+
898
902
// / Construct a suffix tree on the instructions in \p M and outline repeated
899
903
// / strings from that tree.
900
- bool runOnModule (Module &M) override ;
904
+ bool doOutline (Module &M, unsigned &OutlinedFunctionNum) ;
901
905
902
906
// / Return a DISubprogram for OF if one exists, and null otherwise. Helper
903
907
// / function for remark emission.
@@ -1190,13 +1194,11 @@ MachineOutliner::createOutlinedFunction(Module &M, OutlinedFunction &OF,
1190
1194
1191
1195
bool MachineOutliner::outline (Module &M,
1192
1196
std::vector<OutlinedFunction> &FunctionList,
1193
- InstructionMapper &Mapper) {
1197
+ InstructionMapper &Mapper,
1198
+ unsigned &OutlinedFunctionNum) {
1194
1199
1195
1200
bool OutlinedSomething = false ;
1196
1201
1197
- // Number to append to the current outlined function.
1198
- unsigned OutlinedFunctionNum = 0 ;
1199
-
1200
1202
// Sort by benefit. The most beneficial functions should be outlined first.
1201
1203
llvm::stable_sort (FunctionList, [](const OutlinedFunction &LHS,
1202
1204
const OutlinedFunction &RHS) {
@@ -1427,6 +1429,15 @@ bool MachineOutliner::runOnModule(Module &M) {
1427
1429
if (M.empty ())
1428
1430
return false ;
1429
1431
1432
+ // Number to append to the current outlined function.
1433
+ unsigned OutlinedFunctionNum = 0 ;
1434
+
1435
+ if (!doOutline (M, OutlinedFunctionNum))
1436
+ return false ;
1437
+ return true ;
1438
+ }
1439
+
1440
+ bool MachineOutliner::doOutline (Module &M, unsigned &OutlinedFunctionNum) {
1430
1441
MachineModuleInfo &MMI = getAnalysis<MachineModuleInfoWrapperPass>().getMMI ();
1431
1442
1432
1443
// If the user passed -enable-machine-outliner=always or
@@ -1470,7 +1481,8 @@ bool MachineOutliner::runOnModule(Module &M) {
1470
1481
initSizeRemarkInfo (M, MMI, FunctionToInstrCount);
1471
1482
1472
1483
// Outline each of the candidates and return true if something was outlined.
1473
- bool OutlinedSomething = outline (M, FunctionList, Mapper);
1484
+ bool OutlinedSomething =
1485
+ outline (M, FunctionList, Mapper, OutlinedFunctionNum);
1474
1486
1475
1487
// If we outlined something, we definitely changed the MI count of the
1476
1488
// module. If we've asked for size remarks, then output them.
0 commit comments