[PATCH] D124281: [BOLT] Refactor DataAggregator::printLBRHeatMap.

Rahman Lavaee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 10:54:37 PDT 2022


rahmanl created this revision.
rahmanl added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
rahmanl edited the summary of this revision.
rahmanl updated this revision to Diff 424539.
rahmanl added a comment.
rahmanl edited the summary of this revision.
rahmanl published this revision for review.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

More refactoring.


This also fixes some logs that were impacted by D123067 <https://reviews.llvm.org/D123067>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124281

Files:
  bolt/lib/Profile/DataAggregator.cpp


Index: bolt/lib/Profile/DataAggregator.cpp
===================================================================
--- bolt/lib/Profile/DataAggregator.cpp
+++ bolt/lib/Profile/DataAggregator.cpp
@@ -1295,8 +1295,8 @@
              opts::HeatmapMaxAddress);
   uint64_t NumTotalSamples = 0;
 
-  while (hasData()) {
-    if (opts::BasicAggregation) {
+  if (opts::BasicAggregation) {
+    while (hasData()) {
       ErrorOr<PerfBasicSample> SampleRes = parseBasicSample();
       if (std::error_code EC = SampleRes.getError()) {
         if (EC == errc::no_such_process)
@@ -1306,7 +1306,10 @@
       PerfBasicSample &Sample = SampleRes.get();
       HM.registerAddress(Sample.PC);
       NumTotalSamples++;
-    } else {
+    }
+    outs() << "HEATMAP: read " << NumTotalSamples << " basic samples\n";
+  } else {
+    while (hasData()) {
       ErrorOr<PerfBranchSample> SampleRes = parseBranchSample();
       if (std::error_code EC = SampleRes.getError()) {
         if (EC == errc::no_such_process)
@@ -1334,23 +1337,22 @@
       }
       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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124281.424539.patch
Type: text/x-patch
Size: 2046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220422/0af433d2/attachment.bin>


More information about the llvm-commits mailing list