From e20074053da8cfad101f2752fd2e8fb0224ec21c Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 25 Jan 2023 11:37:42 -0800 Subject: [PATCH] [BOLT] Emit a warning about invalid entries in function-order list Move individual warnings under verbosity >= 1, print out a warning with aggregate number. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D142397 --- bolt/lib/Passes/ReorderFunctions.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bolt/lib/Passes/ReorderFunctions.cpp b/bolt/lib/Passes/ReorderFunctions.cpp index 998e0ea..becaadd 100644 --- a/bolt/lib/Passes/ReorderFunctions.cpp +++ b/bolt/lib/Passes/ReorderFunctions.cpp @@ -333,6 +333,7 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) { case RT_USER: { uint32_t Index = 0; + uint32_t InvalidEntries = 0; for (const std::string &Function : readFunctionOrderFile()) { std::vector FuncAddrs; @@ -355,8 +356,10 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) { } if (FuncAddrs.empty()) { - errs() << "BOLT-WARNING: Reorder functions: can't find function for " - << Function << ".\n"; + if (opts::Verbosity >= 1) + errs() << "BOLT-WARNING: Reorder functions: can't find function " + << "for " << Function << "\n"; + ++InvalidEntries; continue; } @@ -366,17 +369,22 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) { BinaryFunction *BF = BC.getFunctionForSymbol(FuncBD->getSymbol()); if (!BF) { - errs() << "BOLT-WARNING: Reorder functions: can't find function for " - << Function << ".\n"; + if (opts::Verbosity >= 1) + errs() << "BOLT-WARNING: Reorder functions: can't find function " + << "for " << Function << "\n"; + ++InvalidEntries; break; } if (!BF->hasValidIndex()) BF->setIndex(Index++); else if (opts::Verbosity > 0) errs() << "BOLT-WARNING: Duplicate reorder entry for " << Function - << ".\n"; + << "\n"; } } + if (InvalidEntries) + errs() << "BOLT-WARNING: Reorder functions: can't find functions for " + << InvalidEntries << " entries in -function-order list\n"; } break; } -- 2.7.4