Skip to content

Commit

Permalink
[BOLT] Force non-relocation mode for heatmap generation
Browse files Browse the repository at this point in the history
Summary: BOLT operates in relocation mode by default when .reloc is in the binary. This changes disables relocation mode for heatmap generation so we can use that for more cases. There's a small separate change that ignores zero-sized symbol in zero-sized code section during function discovery.

(cherry picked from FBD16009610)
  • Loading branch information
WenleiHe authored and maksfb committed Jun 26, 2019
1 parent 0d23cba commit 459add2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bolt/src/RewriteInstance.cpp
Expand Up @@ -1486,6 +1486,11 @@ void RewriteInstance::discoverFileObjects() {
BF->addAlternativeName(UniqueName);
} else {
auto Section = BC->getSectionForAddress(Address);

// Skip zero-size symbol in zero-size section
if (!Section && !SymbolSize)
continue;

assert(Section && "section for functions must be registered.");
BF = BC->createBinaryFunction(UniqueName, *Section, Address,
SymbolSize, IsSimple);
Expand Down Expand Up @@ -1868,6 +1873,12 @@ void RewriteInstance::readSpecialSections() {

BC->HasRelocations = HasTextRelocations &&
(opts::RelocationMode != cl::BOU_FALSE);

// Force non-relocation mode for heatmap generation
if (opts::HeatmapMode) {
BC->HasRelocations = false;
}

if (BC->HasRelocations) {
outs() << "BOLT-INFO: enabling relocation mode\n";
}
Expand Down

0 comments on commit 459add2

Please sign in to comment.