From 1529ec085a31e60fa4de0bed27a5ba88b1a7d7fa Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 22 May 2024 13:53:41 -0700 Subject: [PATCH] [BOLT][NFC] Move out PrintProgramStats from Profile into Rewrite (#93075) Eliminate the dependence of Profile on Passes. Test Plan: NFC --- bolt/lib/Profile/CMakeLists.txt | 1 - bolt/lib/Profile/DataAggregator.cpp | 2 -- bolt/lib/Rewrite/RewriteInstance.cpp | 6 +++++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bolt/lib/Profile/CMakeLists.txt b/bolt/lib/Profile/CMakeLists.txt index 045ac47edb95..ca8b9c34e63b 100644 --- a/bolt/lib/Profile/CMakeLists.txt +++ b/bolt/lib/Profile/CMakeLists.txt @@ -17,6 +17,5 @@ add_llvm_library(LLVMBOLTProfile target_link_libraries(LLVMBOLTProfile PRIVATE LLVMBOLTCore - LLVMBOLTPasses LLVMBOLTUtils ) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index c0fd69b98c82..a9252ea04453 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -613,8 +613,6 @@ Error DataAggregator::readProfile(BinaryContext &BC) { if (std::error_code EC = writeBATYAML(BC, opts::SaveProfile)) report_error("cannot create output data file", EC); } - PrintProgramStats PPS(BAT); - BC.logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(BC)); } return Error::success(); diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index e3b0917ad18a..bb47fca00f7e 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -17,6 +17,7 @@ #include "bolt/Core/MCPlusBuilder.h" #include "bolt/Core/ParallelUtilities.h" #include "bolt/Core/Relocation.h" +#include "bolt/Passes/BinaryPasses.h" #include "bolt/Passes/CacheMetrics.h" #include "bolt/Passes/ReorderFunctions.h" #include "bolt/Profile/BoltAddressTranslation.h" @@ -3281,8 +3282,11 @@ void RewriteInstance::processProfileData() { // Release memory used by profile reader. ProfileReader.reset(); - if (opts::AggregateOnly) + if (opts::AggregateOnly) { + PrintProgramStats PPS(&*BAT); + BC->logBOLTErrorsAndQuitOnFatal(PPS.runOnFunctions(*BC)); exit(0); + } } void RewriteInstance::disassembleFunctions() {