@@ -82,6 +82,8 @@ extern cl::opt<bool> Hugify;
8282extern cl::opt<bool > Instrument;
8383extern cl::opt<bool > KeepNops;
8484extern cl::opt<bool > Lite;
85+ extern cl::list<std::string> PrintOnly;
86+ extern cl::opt<std::string> PrintOnlyFile;
8587extern cl::list<std::string> ReorderData;
8688extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
8789extern cl::opt<bool > TerminalHLT;
@@ -730,6 +732,8 @@ Error RewriteInstance::run() {
730732 << " \n " ;
731733 BC->outs () << " BOLT-INFO: BOLT version: " << BoltRevision << " \n " ;
732734
735+ selectFunctionsToPrint ();
736+
733737 if (Error E = discoverStorage ())
734738 return E;
735739 if (Error E = readSpecialSections ())
@@ -3100,17 +3104,22 @@ static BinaryFunction *getInitFunctionIfStaticBinary(BinaryContext &BC) {
31003104 return BC.getBinaryFunctionAtAddress (BD->getAddress ());
31013105}
31023106
3107+ static void populateFunctionNames (cl::opt<std::string> &FunctionNamesFile,
3108+ cl::list<std::string> &FunctionNames) {
3109+ if (FunctionNamesFile.empty ())
3110+ return ;
3111+ std::ifstream FuncsFile (FunctionNamesFile, std::ios::in);
3112+ std::string FuncName;
3113+ while (std::getline (FuncsFile, FuncName))
3114+ FunctionNames.push_back (FuncName);
3115+ }
3116+
3117+ void RewriteInstance::selectFunctionsToPrint () {
3118+ populateFunctionNames (opts::PrintOnlyFile, opts::PrintOnly);
3119+ }
3120+
31033121void RewriteInstance::selectFunctionsToProcess () {
31043122 // Extend the list of functions to process or skip from a file.
3105- auto populateFunctionNames = [](cl::opt<std::string> &FunctionNamesFile,
3106- cl::list<std::string> &FunctionNames) {
3107- if (FunctionNamesFile.empty ())
3108- return ;
3109- std::ifstream FuncsFile (FunctionNamesFile, std::ios::in);
3110- std::string FuncName;
3111- while (std::getline (FuncsFile, FuncName))
3112- FunctionNames.push_back (FuncName);
3113- };
31143123 populateFunctionNames (opts::FunctionNamesFile, opts::ForceFunctionNames);
31153124 populateFunctionNames (opts::SkipFunctionNamesFile, opts::SkipFunctionNames);
31163125 populateFunctionNames (opts::FunctionNamesFileNR, opts::ForceFunctionNamesNR);
0 commit comments