[llvm] [BOLT] Add itrace aggregation for AUX data (PR #70426)

Jonathan Davies via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 03:51:47 PDT 2023


https://github.com/jonathandavies-arm updated https://github.com/llvm/llvm-project/pull/70426

>From f87cb30f5f0177d283a5baeb2d88b4a3ddf66a7a Mon Sep 17 00:00:00 2001
From: Jonathan Davies <jonathan.davies at arm.com>
Date: Thu, 26 Oct 2023 15:24:00 +0100
Subject: [PATCH] [BOLT] Add itrace aggregation for AUX data

---
 bolt/lib/Profile/DataAggregator.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index b72bd0edf1a2df2..837dbb6e89c5e5a 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -46,6 +46,11 @@ static cl::opt<bool>
                      cl::desc("aggregate basic samples (without LBR info)"),
                      cl::cat(AggregatorCategory));
 
+static cl::opt<std::string>
+    ITraceAggregation("itrace",
+                      cl::desc("Generate LBR info with perf itrace argument"),
+                      cl::cat(AggregatorCategory));
+
 static cl::opt<bool>
 FilterMemProfile("filter-mem-profile",
   cl::desc("if processing a memory profile, filter out stack or heap accesses "
@@ -155,6 +160,8 @@ void DataAggregator::findPerfExecutable() {
 }
 
 void DataAggregator::start() {
+  std::string ItracePerfScriptArgs;
+
   outs() << "PERF2BOLT: Starting data aggregation job for " << Filename << "\n";
 
   // Don't launch perf for pre-aggregated files
@@ -163,16 +170,23 @@ void DataAggregator::start() {
 
   findPerfExecutable();
 
-  if (opts::BasicAggregation)
+  if (opts::BasicAggregation) {
     launchPerfProcess("events without LBR",
                       MainEventsPPI,
                       "script -F pid,event,ip",
                       /*Wait = */false);
-  else
+  } else if (!opts::ITraceAggregation.empty()) {
+    ItracePerfScriptArgs = llvm::formatv(
+        "script -F pid,ip,brstack --itrace={0}", opts::ITraceAggregation);
+    launchPerfProcess("branch events with itrace", MainEventsPPI,
+                      ItracePerfScriptArgs.c_str(),
+                      /*Wait = */ false);
+  } else {
     launchPerfProcess("branch events",
                       MainEventsPPI,
                       "script -F pid,ip,brstack",
                       /*Wait = */false);
+  }
 
   // Note: we launch script for mem events regardless of the option, as the
   //       command fails fairly fast if mem events were not collected.



More information about the llvm-commits mailing list