[BOLT] Print heatmap from perf2bolt (#139194)

Add perf2bolt `--heatmap` option to produce heatmaps during profile
aggregation.

Distinguish exclusive mode (`llvm-bolt-heatmap`) and optional mode 
(`perf2bolt --heatmap`), which impacts perf.data handling:
exclusive mode covers all addresses, whereas optional mode consumes
attached profile only covering function addresses.

Test Plan: updated per2bolt tests:
- pre-aggregated-perf.test: pre-aggregated data,
- bolt-address-translation-yaml.test: pre-aggregated + BOLTed input,
- perf_test.test: no-LBR perf data.
This commit is contained in:
Amir Ayupov
2025-05-13 13:23:18 -07:00
committed by GitHub
parent 7f4febde10
commit 0289ca09be
10 changed files with 73 additions and 41 deletions

View File

@@ -1453,7 +1453,8 @@ void RewriteInstance::updateRtFiniReloc() {
}
void RewriteInstance::registerFragments() {
if (!BC->HasSplitFunctions || opts::HeatmapMode)
if (!BC->HasSplitFunctions ||
opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive)
return;
// Process fragments with ambiguous parents separately as they are typically a
@@ -1998,7 +1999,7 @@ Error RewriteInstance::readSpecialSections() {
BC->getUniqueSectionByName(BoltAddressTranslation::SECTION_NAME)) {
BC->HasBATSection = true;
// Do not read BAT when plotting a heatmap
if (!opts::HeatmapMode) {
if (opts::HeatmapMode != opts::HeatmapModeKind::HM_Exclusive) {
if (std::error_code EC = BAT->parse(BC->outs(), BATSec->getContents())) {
BC->errs() << "BOLT-ERROR: failed to parse BOLT address translation "
"table.\n";
@@ -2037,7 +2038,7 @@ Error RewriteInstance::readSpecialSections() {
}
// Force non-relocation mode for heatmap generation
if (opts::HeatmapMode)
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive)
BC->HasRelocations = false;
if (BC->HasRelocations)