[PATCH] D125255: [llvm-profgen] Support a threshold to control hiding warning summaries
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 9 16:50:26 PDT 2022
wlei updated this revision to Diff 428239.
wlei added a comment.
Updating D125255 <https://reviews.llvm.org/D125255>: [llvm-profgen] Support a threshold to control hiding warning summaries
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125255/new/
https://reviews.llvm.org/D125255
Files:
llvm/tools/llvm-profgen/ErrorHandling.h
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/llvm-profgen.cpp
Index: llvm/tools/llvm-profgen/llvm-profgen.cpp
===================================================================
--- llvm/tools/llvm-profgen/llvm-profgen.cpp
+++ llvm/tools/llvm-profgen/llvm-profgen.cpp
@@ -71,6 +71,20 @@
"from it instead of the executable binary."),
cl::cat(ProfGenCategory));
+cl::opt<unsigned> WarningSummaryThres(
+ "warning-summary-threshold", llvm::cl::init(20),
+ llvm::cl::desc("Print out the warning summary only if it's above the "
+ "threshold(in percentage), default value is 20%."),
+ llvm::cl::Optional);
+
+cl::opt<bool>
+ VerboseMode("verbose", cl::init(false), cl::ZeroOrMore,
+ cl::desc("Enable verbose mode, i.e. print out all warnings no "
+ "matter if it's below the threshold."));
+
+static cl::alias VA("v", cl::desc("Alias for --verbose"),
+ cl::aliasopt(VerboseMode));
+
extern cl::opt<bool> ShowDisassemblyOnly;
extern cl::opt<bool> ShowSourceLocations;
extern cl::opt<bool> SkipSymbolization;
@@ -125,6 +139,9 @@
exitWithError("--show-source-locations should work together with "
"--show-disassembly-only!");
}
+
+ if (WarningSummaryThres > 100)
+ exitWithError("--warning-summary-threshold should be between 0 and 100.");
}
static PerfInputFile getPerfInputFile() {
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ 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.",
+ 0);
}
void ProfiledBinary::load() {
Index: llvm/tools/llvm-profgen/ErrorHandling.h
===================================================================
--- llvm/tools/llvm-profgen/ErrorHandling.h
+++ 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,9 @@
using namespace llvm;
+extern cl::opt<unsigned> WarningSummaryThres;
+extern cl::opt<bool> VerboseMode;
+
[[noreturn]] inline void exitWithError(const Twine &Message,
StringRef Whence = StringRef(),
StringRef Hint = StringRef()) {
@@ -46,11 +50,15 @@
exitWithError(EO.takeError(), std::forward<Ts>(Args)...);
}
-inline void emitWarningSummary(uint64_t Num, uint64_t Total, StringRef Msg) {
+inline void emitWarningSummary(uint64_t Num, uint64_t Total, StringRef Msg,
+ unsigned Thres = WarningSummaryThres) {
if (!Total || !Num)
return;
- WithColor::warning() << format("%.2f", static_cast<double>(Num) * 100 / Total)
- << "%(" << Num << "/" << Total << ") " << Msg << "\n";
+
+ double P = static_cast<double>(Num) * 100 / Total;
+ if (VerboseMode || P > Thres)
+ WithColor::warning() << format("%.2f", P) << "%(" << Num << "/" << Total
+ << ") " << Msg << "\n";
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125255.428239.patch
Type: text/x-patch
Size: 3473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220509/4a9871e8/attachment.bin>
More information about the llvm-commits
mailing list