@@ -514,6 +514,10 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
514514 deleteTempFiles ();
515515
516516heatmap:
517+ // Sort parsed traces for faster processing.
518+ if (!opts::BasicAggregation)
519+ llvm::sort (Traces, llvm::less_first ());
520+
517521 if (!opts::HeatmapMode)
518522 return Error::success ();
519523
@@ -1283,15 +1287,15 @@ std::error_code DataAggregator::parseAggregatedLBREntry() {
12831287 }
12841288
12851289 if (Type == BRANCH) {
1286- Addr[2 ] = Location (Trace::EXTERNAL );
1290+ Addr[2 ] = Location (Trace::BR_ONLY );
12871291 }
12881292
12891293 Trace T{Addr[0 ]->Offset , Addr[1 ]->Offset , Addr[2 ]->Offset };
12901294 TakenBranchInfo TI{(uint64_t )Count, (uint64_t )Mispreds};
12911295
12921296 Traces.emplace_back (T, TI);
12931297
1294- if (Addr[2 ]->Offset )
1298+ if (Addr[2 ]->Offset != Trace::BR_ONLY )
12951299 NumTraces += Count;
12961300 NumTotalSamples += Count;
12971301
@@ -1305,7 +1309,7 @@ bool DataAggregator::ignoreKernelInterrupt(LBREntry &LBR) const {
13051309
13061310std::error_code DataAggregator::printLBRHeatMap () {
13071311 outs () << " PERF2BOLT: parse branch events...\n " ;
1308- NamedRegionTimer T (" parseBranch " , " Parsing branch events " , TimerGroupName,
1312+ NamedRegionTimer T (" buildHeatmap " , " Building heatmap " , TimerGroupName,
13091313 TimerGroupDesc, opts::TimeAggregator);
13101314
13111315 if (BC->IsLinuxKernel ) {
@@ -1342,7 +1346,7 @@ std::error_code DataAggregator::printLBRHeatMap() {
13421346 for (const auto &[PC, Hits] : BasicSamples)
13431347 HM.registerAddress (PC, Hits);
13441348 for (const auto &[Trace, Info] : Traces)
1345- if (Trace.To )
1349+ if (Trace.To != Trace::BR_ONLY )
13461350 HM.registerAddressRange (Trace.From , Trace.To , Info.TakenCount );
13471351
13481352 if (HM.getNumInvalidRanges ())
@@ -1540,7 +1544,7 @@ void DataAggregator::processBranchEvents() {
15401544 TimerGroupName, TimerGroupDesc, opts::TimeAggregator);
15411545
15421546 for (const auto &[Trace, Info] : Traces) {
1543- if (Trace.To )
1547+ if (Trace.To != Trace::BR_ONLY )
15441548 doTrace (Trace, Info.TakenCount );
15451549 if (Trace.Branch != Trace::FT_ONLY &&
15461550 Trace.Branch != Trace::FT_EXTERNAL_ORIGIN)
0 commit comments