From e59e580116b055bd2057de0da5cc35fffd16a590 Mon Sep 17 00:00:00 2001 From: Rahman Lavaee Date: Mon, 25 Apr 2022 11:32:13 -0700 Subject: [PATCH] [BOLT] Refactor DataAggregator::printLBRHeatMap. This also fixes some logs that were impacted by D123067. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D124281 --- bolt/lib/Profile/DataAggregator.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 5b7853e..7992daaa 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1295,8 +1295,8 @@ std::error_code DataAggregator::printLBRHeatMap() { opts::HeatmapMaxAddress); uint64_t NumTotalSamples = 0; - while (hasData()) { - if (opts::BasicAggregation) { + if (opts::BasicAggregation) { + while (hasData()) { ErrorOr SampleRes = parseBasicSample(); if (std::error_code EC = SampleRes.getError()) { if (EC == errc::no_such_process) @@ -1306,7 +1306,10 @@ std::error_code DataAggregator::printLBRHeatMap() { PerfBasicSample &Sample = SampleRes.get(); HM.registerAddress(Sample.PC); NumTotalSamples++; - } else { + } + outs() << "HEATMAP: read " << NumTotalSamples << " basic samples\n"; + } else { + while (hasData()) { ErrorOr SampleRes = parseBranchSample(); if (std::error_code EC = SampleRes.getError()) { if (EC == errc::no_such_process) @@ -1334,23 +1337,22 @@ std::error_code DataAggregator::printLBRHeatMap() { } NumTotalSamples += Sample.LBR.size(); } + outs() << "HEATMAP: read " << NumTotalSamples << " LBR samples\n"; + outs() << "HEATMAP: " << FallthroughLBRs.size() << " unique traces\n"; } if (!NumTotalSamples) { - if (!opts::BasicAggregation) { + if (opts::BasicAggregation) { + errs() << "HEATMAP-ERROR: no basic event samples detected in profile. " + "Cannot build heatmap."; + } else { errs() << "HEATMAP-ERROR: no LBR traces detected in profile. " "Cannot build heatmap. Use -nl for building heatmap from " "basic events.\n"; - } else { - errs() << "HEATMAP-ERROR: no samples detected in profile. " - "Cannot build heatmap."; } exit(1); } - outs() << "HEATMAP: read " << NumTotalSamples << " LBR samples\n"; - outs() << "HEATMAP: " << FallthroughLBRs.size() << " unique traces\n"; - outs() << "HEATMAP: building heat map...\n"; for (const auto &LBR : FallthroughLBRs) { -- 2.7.4