Skip to content

Commit 22bea0c

Browse files
[BOLT] Add itrace aggregation for AUX data (#70426)
If you have a perf.data with Arm ETM data the only way to use perf2bolt with Branch Aggregation is to first run `perf inject --itrace=l64i1us -o perf-brstack.data` and then pass the new perf-brstack.data into perf2bolt. perf2bolt then runs `perf script -F pid,ip,brstack` to produce the brstacks. This PR adds `--itrace` arg to perf2bolt to enable Itrace Aggregation. It takes a string which is what is passed to the `perf script -F pid,ip,brstack --itrace={0}`. This command produces the brstacks without having to run perf inject and creating a new perf.data file.
1 parent 684b8e1 commit 22bea0c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ static cl::opt<bool>
4646
cl::desc("aggregate basic samples (without LBR info)"),
4747
cl::cat(AggregatorCategory));
4848

49+
static cl::opt<std::string>
50+
ITraceAggregation("itrace",
51+
cl::desc("Generate LBR info with perf itrace argument"),
52+
cl::cat(AggregatorCategory));
53+
4954
static cl::opt<bool>
5055
FilterMemProfile("filter-mem-profile",
5156
cl::desc("if processing a memory profile, filter out stack or heap accesses "
@@ -163,16 +168,23 @@ void DataAggregator::start() {
163168

164169
findPerfExecutable();
165170

166-
if (opts::BasicAggregation)
171+
if (opts::BasicAggregation) {
167172
launchPerfProcess("events without LBR",
168173
MainEventsPPI,
169174
"script -F pid,event,ip",
170175
/*Wait = */false);
171-
else
176+
} else if (!opts::ITraceAggregation.empty()) {
177+
std::string ItracePerfScriptArgs = llvm::formatv(
178+
"script -F pid,ip,brstack --itrace={0}", opts::ITraceAggregation);
179+
launchPerfProcess("branch events with itrace", MainEventsPPI,
180+
ItracePerfScriptArgs.c_str(),
181+
/*Wait = */ false);
182+
} else {
172183
launchPerfProcess("branch events",
173184
MainEventsPPI,
174185
"script -F pid,ip,brstack",
175186
/*Wait = */false);
187+
}
176188

177189
// Note: we launch script for mem events regardless of the option, as the
178190
// command fails fairly fast if mem events were not collected.

0 commit comments

Comments
 (0)