[BOLT][NFC] Split out parsePerfData (#145248)

This commit is contained in:
Amir Ayupov
2025-06-24 09:39:51 -07:00
committed by GitHub
parent 85d250c96e
commit f6973baf28
2 changed files with 21 additions and 19 deletions

View File

@@ -374,6 +374,9 @@ private:
/// Parse a single pair of binary full path and associated build-id
std::optional<std::pair<StringRef, StringRef>> parseNameBuildIDPair();
/// Coordinate reading and parsing of perf.data file
void parsePerfData(BinaryContext &BC);
/// Coordinate reading and parsing of pre-aggregated file
///
/// The regular perf2bolt aggregation job is to read perf output directly.

View File

@@ -466,9 +466,7 @@ int DataAggregator::prepareToParse(StringRef Name, PerfProcessInfo &Process,
return PI.ReturnCode;
}
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
this->BC = &BC;
void DataAggregator::parsePerfData(BinaryContext &BC) {
auto ErrorCallback = [](int ReturnCode, StringRef ErrBuf) {
errs() << "PERF-ERROR: return code " << ReturnCode << "\n" << ErrBuf;
exit(1);
@@ -481,11 +479,6 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
ErrorCallback(ReturnCode, ErrBuf);
};
if (opts::ReadPreAggregated) {
parsePreAggregated();
goto heatmap;
}
if (std::optional<StringRef> FileBuildID = BC.getFileBuildID()) {
outs() << "BOLT-INFO: binary build-id is: " << *FileBuildID << "\n";
processFileBuildID(*FileBuildID);
@@ -534,22 +527,28 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
<< '\n';
deleteTempFiles();
}
Error DataAggregator::preprocessProfile(BinaryContext &BC) {
this->BC = &BC;
if (opts::ReadPreAggregated) {
parsePreAggregated();
} else {
parsePerfData(BC);
}
heatmap:
// Sort parsed traces for faster processing.
llvm::sort(Traces, llvm::less_first());
if (!opts::HeatmapMode)
return Error::success();
if (opts::HeatmapMode) {
if (std::error_code EC = printLBRHeatMap())
return errorCodeToError(EC);
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive)
exit(0);
}
if (std::error_code EC = printLBRHeatMap())
return errorCodeToError(EC);
if (opts::HeatmapMode == opts::HeatmapModeKind::HM_Optional)
return Error::success();
assert(opts::HeatmapMode == opts::HeatmapModeKind::HM_Exclusive);
exit(0);
return Error::success();
}
Error DataAggregator::readProfile(BinaryContext &BC) {