Skip to content

Commit

Permalink
[Bolt] Reduce verbosity while reporting hash collisions
Browse files Browse the repository at this point in the history
Summary:
Don't report all data objects with hash collisions by default. Only
report the summary, and use -v=1 for providing the full list.

(cherry picked from FBD8372241)
  • Loading branch information
maksfb committed Jun 12, 2018
1 parent 706abb6 commit 232046f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bolt/src/BinaryContext.cpp
Expand Up @@ -32,6 +32,8 @@ namespace opts {

extern cl::OptionCategory BoltCategory;

extern cl::opt<unsigned> Verbosity;

static cl::opt<bool>
PrintDebugInfo("print-debug-info",
cl::desc("print debug info when printing functions"),
Expand Down Expand Up @@ -315,6 +317,7 @@ void BinaryContext::generateSymbolHashes() {
SymData.find_first_not_of(0) == StringRef::npos);
};

uint64_t NumCollisions = 0;
for (auto &Entry : BinaryDataMap) {
auto &BD = *Entry.second;
auto Name = BD.getName();
Expand Down Expand Up @@ -350,8 +353,11 @@ void BinaryContext::generateSymbolHashes() {
// Ignore collisions for symbols that appear to be padding
// (i.e. all zeros or a "hole")
if (!isPadding(BD)) {
outs() << "BOLT-WARNING: collision detected when hashing " << BD
<< " with new name (" << NewName << "), skipping.\n";
if (opts::Verbosity) {
errs() << "BOLT-WARNING: collision detected when hashing " << BD
<< " with new name (" << NewName << "), skipping.\n";
}
++NumCollisions;
}
continue;
}
Expand All @@ -362,6 +368,13 @@ void BinaryContext::generateSymbolHashes() {
"there should be a 1:1 mapping between names and symbols");
GlobalSymbols[NewName] = &BD;
}
if (NumCollisions) {
errs() << "BOLT-WARNING: " << NumCollisions
<< " collisions detected while hashing binary objects";
if (!opts::Verbosity)
errs() << ". Use -v=1 to see the list.";
errs() << '\n';
}
}

void BinaryContext::postProcessSymbolTable() {
Expand All @@ -375,7 +388,7 @@ void BinaryContext::postProcessSymbolTable() {
!BD->getSize() &&
!BD->isAbsolute() &&
BD->getSection()) {
outs() << "BOLT-WARNING: zero sized top level symbol: " << *BD << "\n";
errs() << "BOLT-WARNING: zero sized top level symbol: " << *BD << "\n";
Valid = false;
}
}
Expand Down

0 comments on commit 232046f

Please sign in to comment.