Skip to content

Commit f6973ba

Browse files
authored
[BOLT][NFC] Split out parsePerfData (#145248)
1 parent 85d250c commit f6973ba

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ class DataAggregator : public DataReader {
374374
/// Parse a single pair of binary full path and associated build-id
375375
std::optional<std::pair<StringRef, StringRef>> parseNameBuildIDPair();
376376

377+
/// Coordinate reading and parsing of perf.data file
378+
void parsePerfData(BinaryContext &BC);
379+
377380
/// Coordinate reading and parsing of pre-aggregated file
378381
///
379382
/// The regular perf2bolt aggregation job is to read perf output directly.

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,7 @@ int DataAggregator::prepareToParse(StringRef Name, PerfProcessInfo &Process,
466466
return PI.ReturnCode;
467467
}
468468

469-
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
470-
this->BC = &BC;
471-
469+
void DataAggregator::parsePerfData(BinaryContext &BC) {
472470
auto ErrorCallback = [](int ReturnCode, StringRef ErrBuf) {
473471
errs() << "PERF-ERROR: return code " << ReturnCode << "\n" << ErrBuf;
474472
exit(1);
@@ -481,11 +479,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
481479
ErrorCallback(ReturnCode, ErrBuf);
482480
};
483481

484-
if (opts::ReadPreAggregated) {
485-
parsePreAggregated();
486-
goto heatmap;
487-
}
488-
489482
if (std::optional<StringRef> FileBuildID = BC.getFileBuildID()) {
490483
outs() << "BOLT-INFO: binary build-id is: " << *FileBuildID << "\n";
491484
processFileBuildID(*FileBuildID);
@@ -534,22 +527,28 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
534527
<< '\n';
535528

536529
deleteTempFiles();
530+
}
537531

538-
heatmap:
539-
// Sort parsed traces for faster processing.
540-
llvm::sort(Traces, llvm::less_first());
532+
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
533+
this->BC = &BC;
541534

542-
if (!opts::HeatmapMode)
543-
return Error::success();
535+
if (opts::ReadPreAggregated) {
536+
parsePreAggregated();
537+
} else {
538+
parsePerfData(BC);
539+
}
544540

545-
if (std::error_code EC = printLBRHeatMap())
546-
return errorCodeToError(EC);
541+
// Sort parsed traces for faster processing.
542+
llvm::sort(Traces, llvm::less_first());
547543

548-
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Optional)
549-
return Error::success();
544+
if (opts::HeatmapMode) {
545+
if (std::error_code EC = printLBRHeatMap())
546+
return errorCodeToError(EC);
547+
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive)
548+
exit(0);
549+
}
550550

551-
assert(opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive);
552-
exit(0);
551+
return Error::success();
553552
}
554553

555554
Error DataAggregator::readProfile(BinaryContext &BC) {

0 commit comments

Comments
 (0)