@@ -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
555554Error DataAggregator::readProfile (BinaryContext &BC) {
0 commit comments