mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[BOLT][NFC] Split out parsePerfData (#145248)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user