diff --git a/llvm/tools/llvm-profgen/ErrorHandling.h b/llvm/tools/llvm-profgen/ErrorHandling.h --- a/llvm/tools/llvm-profgen/ErrorHandling.h +++ b/llvm/tools/llvm-profgen/ErrorHandling.h @@ -10,6 +10,7 @@ #define LLVM_TOOLS_LLVM_PROFGEN_ERRORHANDLING_H #include "llvm/ADT/Twine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" @@ -18,6 +19,8 @@ using namespace llvm; +extern cl::opt VerboseMode; + [[noreturn]] inline void exitWithError(const Twine &Message, StringRef Whence = StringRef(), StringRef Hint = StringRef()) { @@ -46,11 +49,12 @@ exitWithError(EO.takeError(), std::forward(Args)...); } -inline void emitWarningSummary(uint64_t Num, uint64_t Total, StringRef Msg) { - if (!Total || !Num) - return; - WithColor::warning() << format("%.2f", static_cast(Num) * 100 / Total) - << "%(" << Num << "/" << Total << ") " << Msg << "\n"; +inline void emitWarningSummary(uint64_t Num, uint64_t Total, StringRef Msg, + bool AlwaysEmit = false) { + if (Total && Num && (VerboseMode || AlwaysEmit)) + WithColor::warning() << format("%.2f", + static_cast(Num) * 100 / Total) + << "%(" << Num << "/" << Total << ") " << Msg << "\n"; } #endif diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp --- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp +++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp @@ -188,7 +188,8 @@ } emitWarningSummary(NoFuncEntryNum, BinaryFunctions.size(), "of functions failed to determine function entry due to " - "inconsistent name from symbol table and dwarf info."); + "inconsistent name from symbol table and dwarf info.", + true); } void ProfiledBinary::load() { diff --git a/llvm/tools/llvm-profgen/llvm-profgen.cpp b/llvm/tools/llvm-profgen/llvm-profgen.cpp --- a/llvm/tools/llvm-profgen/llvm-profgen.cpp +++ b/llvm/tools/llvm-profgen/llvm-profgen.cpp @@ -71,6 +71,13 @@ "from it instead of the executable binary."), cl::cat(ProfGenCategory)); +cl::opt + VerboseMode("verbose", cl::init(false), cl::ZeroOrMore, + cl::desc("Enable verbose mode, i.e. print out all warnings.")); + +static cl::alias VA("v", cl::desc("Alias for --verbose"), + cl::aliasopt(VerboseMode)); + extern cl::opt ShowDisassemblyOnly; extern cl::opt ShowSourceLocations; extern cl::opt SkipSymbolization;