@@ -108,15 +108,6 @@ TimeAggregator("time-aggr",
108
108
cl::ZeroOrMore,
109
109
cl::cat(AggregatorCategory));
110
110
111
- static cl::opt<bool >
112
- UseEventPC (" use-event-pc" ,
113
- cl::desc (" use event PC in combination with LBR sampling" ),
114
- cl::cat(AggregatorCategory));
115
-
116
- static cl::opt<bool > WriteAutoFDOData (
117
- " autofdo" , cl::desc(" generate autofdo textual data instead of bolt data" ),
118
- cl::cat(AggregatorCategory));
119
-
120
111
} // namespace opts
121
112
122
113
namespace {
@@ -187,15 +178,13 @@ void DataAggregator::start() {
187
178
/* Wait = */ false );
188
179
} else if (!opts::ITraceAggregation.empty ()) {
189
180
std::string ItracePerfScriptArgs = llvm::formatv (
190
- " script -F pid,ip, brstack --itrace={0}" , opts::ITraceAggregation);
181
+ " script -F pid,brstack --itrace={0}" , opts::ITraceAggregation);
191
182
launchPerfProcess (" branch events with itrace" , MainEventsPPI,
192
183
ItracePerfScriptArgs.c_str (),
193
184
/* Wait = */ false );
194
185
} else {
195
- launchPerfProcess (" branch events" ,
196
- MainEventsPPI,
197
- " script -F pid,ip,brstack" ,
198
- /* Wait = */ false );
186
+ launchPerfProcess (" branch events" , MainEventsPPI, " script -F pid,brstack" ,
187
+ /* Wait = */ false );
199
188
}
200
189
201
190
// Note: we launch script for mem events regardless of the option, as the
@@ -381,67 +370,6 @@ void DataAggregator::parsePreAggregated() {
381
370
}
382
371
}
383
372
384
- std::error_code DataAggregator::writeAutoFDOData (StringRef OutputFilename) {
385
- outs () << " PERF2BOLT: writing data for autofdo tools...\n " ;
386
- NamedRegionTimer T (" writeAutoFDO" , " Processing branch events" , TimerGroupName,
387
- TimerGroupDesc, opts::TimeAggregator);
388
-
389
- std::error_code EC;
390
- raw_fd_ostream OutFile (OutputFilename, EC, sys::fs::OpenFlags::OF_None);
391
- if (EC)
392
- return EC;
393
-
394
- // Format:
395
- // number of unique traces
396
- // from_1-to_1:count_1
397
- // from_2-to_2:count_2
398
- // ......
399
- // from_n-to_n:count_n
400
- // number of unique sample addresses
401
- // addr_1:count_1
402
- // addr_2:count_2
403
- // ......
404
- // addr_n:count_n
405
- // number of unique LBR entries
406
- // src_1->dst_1:count_1
407
- // src_2->dst_2:count_2
408
- // ......
409
- // src_n->dst_n:count_n
410
-
411
- const uint64_t FirstAllocAddress = this ->BC ->FirstAllocAddress ;
412
-
413
- // AutoFDO addresses are relative to the first allocated loadable program
414
- // segment
415
- auto filterAddress = [&FirstAllocAddress](uint64_t Address) -> uint64_t {
416
- if (Address < FirstAllocAddress)
417
- return 0 ;
418
- return Address - FirstAllocAddress;
419
- };
420
-
421
- OutFile << FallthroughLBRs.size () << " \n " ;
422
- for (const auto &[Trace, Info] : FallthroughLBRs) {
423
- OutFile << formatv (" {0:x-}-{1:x-}:{2}\n " , filterAddress (Trace.From ),
424
- filterAddress (Trace.To ),
425
- Info.InternCount + Info.ExternCount );
426
- }
427
-
428
- OutFile << BasicSamples.size () << " \n " ;
429
- for (const auto [PC, HitCount] : BasicSamples)
430
- OutFile << formatv (" {0:x-}:{1}\n " , filterAddress (PC), HitCount);
431
-
432
- OutFile << BranchLBRs.size () << " \n " ;
433
- for (const auto &[Trace, Info] : BranchLBRs) {
434
- OutFile << formatv (" {0:x-}->{1:x-}:{2}\n " , filterAddress (Trace.From ),
435
- filterAddress (Trace.To ), Info.TakenCount );
436
- }
437
-
438
- outs () << " PERF2BOLT: wrote " << FallthroughLBRs.size () << " unique traces, "
439
- << BasicSamples.size () << " sample addresses and " << BranchLBRs.size ()
440
- << " unique branches to " << OutputFilename << " \n " ;
441
-
442
- return std::error_code ();
443
- }
444
-
445
373
void DataAggregator::filterBinaryMMapInfo () {
446
374
if (opts::FilterPID) {
447
375
auto MMapInfoIter = BinaryMMapInfo.find (opts::FilterPID);
@@ -583,15 +511,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
583
511
(opts::BasicAggregation && parseBasicEvents ()))
584
512
errs () << " PERF2BOLT: failed to parse samples\n " ;
585
513
586
- // We can finish early if the goal is just to generate data for autofdo
587
- if (opts::WriteAutoFDOData) {
588
- if (std::error_code EC = writeAutoFDOData (opts::OutputFilename))
589
- errs () << " Error writing autofdo data to file: " << EC.message () << " \n " ;
590
-
591
- deleteTempFiles ();
592
- exit (0 );
593
- }
594
-
595
514
// Special handling for memory events
596
515
if (prepareToParse (" mem events" , MemEventsPPI, MemEventsErrorCallback))
597
516
return Error::success ();
@@ -1158,14 +1077,6 @@ ErrorOr<DataAggregator::PerfBranchSample> DataAggregator::parseBranchSample() {
1158
1077
return make_error_code (errc::no_such_process);
1159
1078
}
1160
1079
1161
- while (checkAndConsumeFS ()) {
1162
- }
1163
-
1164
- ErrorOr<uint64_t > PCRes = parseHexField (FieldSeparator, true );
1165
- if (std::error_code EC = PCRes.getError ())
1166
- return EC;
1167
- Res.PC = PCRes.get ();
1168
-
1169
1080
if (checkAndConsumeNewLine ())
1170
1081
return Res;
1171
1082
@@ -1472,9 +1383,9 @@ std::error_code DataAggregator::printLBRHeatMap() {
1472
1383
uint64_t DataAggregator::parseLBRSample (const PerfBranchSample &Sample,
1473
1384
bool NeedsSkylakeFix) {
1474
1385
uint64_t NumTraces{0 };
1475
- // LBRs are stored in reverse execution order. NextPC refers to the next
1476
- // recorded executed PC .
1477
- uint64_t NextPC = opts::UseEventPC ? Sample. PC : 0 ;
1386
+ // LBRs are stored in reverse execution order. NextLBR refers to the next
1387
+ // executed branch record .
1388
+ const LBREntry *NextLBR = nullptr ;
1478
1389
uint32_t NumEntry = 0 ;
1479
1390
for (const LBREntry &LBR : Sample.LBR ) {
1480
1391
++NumEntry;
@@ -1486,10 +1397,10 @@ uint64_t DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
1486
1397
// chronological order)
1487
1398
if (NeedsSkylakeFix && NumEntry <= 2 )
1488
1399
continue ;
1489
- if (NextPC ) {
1400
+ if (NextLBR ) {
1490
1401
// Record fall-through trace.
1491
1402
const uint64_t TraceFrom = LBR.To ;
1492
- const uint64_t TraceTo = NextPC ;
1403
+ const uint64_t TraceTo = NextLBR-> From ;
1493
1404
const BinaryFunction *TraceBF =
1494
1405
getBinaryFunctionContainingAddress (TraceFrom);
1495
1406
if (TraceBF && TraceBF->containsAddress (TraceTo)) {
@@ -1524,7 +1435,7 @@ uint64_t DataAggregator::parseLBRSample(const PerfBranchSample &Sample,
1524
1435
}
1525
1436
++NumTraces;
1526
1437
}
1527
- NextPC = LBR. From ;
1438
+ NextLBR = & LBR;
1528
1439
1529
1440
uint64_t From = getBinaryFunctionContainingAddress (LBR.From ) ? LBR.From : 0 ;
1530
1441
uint64_t To = getBinaryFunctionContainingAddress (LBR.To ) ? LBR.To : 0 ;
@@ -1561,8 +1472,6 @@ std::error_code DataAggregator::parseBranchEvents() {
1561
1472
++NumSamples;
1562
1473
1563
1474
PerfBranchSample &Sample = SampleRes.get ();
1564
- if (opts::WriteAutoFDOData)
1565
- ++BasicSamples[Sample.PC ];
1566
1475
1567
1476
if (Sample.LBR .empty ()) {
1568
1477
++NumSamplesNoLBR;
0 commit comments