aboutsummaryrefslogtreecommitdiff
path: root/bolt/lib/Rewrite/BinaryPassManager.cpp
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2024-02-12 14:53:53 -0800
committerGitHub <noreply@github.com>2024-02-12 14:53:53 -0800
commit52cf07116bf0a8cab87b0f55176d198bcaa02575 (patch)
tree65e5bb467a7592f93a79cfa87540838516cdb434 /bolt/lib/Rewrite/BinaryPassManager.cpp
parent93cdd1b5cfa3735c599949b77e24dbfbe570441a (diff)
downloadllvm-52cf07116bf0a8cab87b0f55176d198bcaa02575.zip
llvm-52cf07116bf0a8cab87b0f55176d198bcaa02575.tar.gz
llvm-52cf07116bf0a8cab87b0f55176d198bcaa02575.tar.bz2
[BOLT][NFC] Log through JournalingStreams (#81524)
Make core BOLT functionality more friendly to being used as a library instead of in our standalone driver llvm-bolt. To accomplish this, we augment BinaryContext with journaling streams that are to be used by most BOLT code whenever something needs to be logged to the screen. Users of the library can decide if logs should be printed to a file, no file or to the screen, as before. To illustrate this, this patch adds a new option `--log-file` that allows the user to redirect BOLT logging to a file on disk or completely hide it by using `--log-file=/dev/null`. Future BOLT code should now use `BinaryContext::outs()` for printing important messages instead of `llvm::outs()`. A new test log.test enforces this by verifying that no strings are print to screen once the `--log-file` option is used. In previous patches we also added a new BOLTError class to report common and fatal errors, so code shouldn't call exit(1) now. To easily handle problems as before (by quitting with exit(1)), callers can now use `BinaryContext::logBOLTErrorsAndQuitOnFatal(Error)` whenever code needs to deal with BOLT errors. To test this, we have fatal.s that checks we are correctly quitting and printing a fatal error to the screen. Because this is a significant change by itself, not all code was yet ported. Code from Profiler libs (DataAggregator and friends) still print errors directly to screen. Co-authored-by: Rafael Auler <rafaelauler@fb.com> Test Plan: NFC
Diffstat (limited to 'bolt/lib/Rewrite/BinaryPassManager.cpp')
-rw-r--r--bolt/lib/Rewrite/BinaryPassManager.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/bolt/lib/Rewrite/BinaryPassManager.cpp b/bolt/lib/Rewrite/BinaryPassManager.cpp
index cad8018..489b33f 100644
--- a/bolt/lib/Rewrite/BinaryPassManager.cpp
+++ b/bolt/lib/Rewrite/BinaryPassManager.cpp
@@ -281,13 +281,14 @@ Error BinaryFunctionPassManager::runPasses() {
formatv("{0:2}_{1}", PassIdx, Pass->getName()).str();
if (opts::Verbosity > 0)
- outs() << "BOLT-INFO: Starting pass: " << Pass->getName() << "\n";
+ BC.outs() << "BOLT-INFO: Starting pass: " << Pass->getName() << "\n";
NamedRegionTimer T(Pass->getName(), Pass->getName(), TimerGroupName,
TimerGroupDesc, TimeOpts);
Error E = Error::success();
callWithDynoStats(
+ BC.outs(),
[this, &E, &Pass] {
E = joinErrors(std::move(E), Pass->runOnFunctions(BC));
},
@@ -308,7 +309,7 @@ Error BinaryFunctionPassManager::runPasses() {
}
if (opts::Verbosity > 0)
- outs() << "BOLT-INFO: Finished pass: " << Pass->getName() << "\n";
+ BC.outs() << "BOLT-INFO: Finished pass: " << Pass->getName() << "\n";
if (!opts::PrintAll && !opts::DumpDotAll && !Pass->printPass())
continue;
@@ -321,7 +322,7 @@ Error BinaryFunctionPassManager::runPasses() {
if (!Pass->shouldPrint(Function))
continue;
- Function.print(outs(), Message);
+ Function.print(BC.outs(), Message);
if (opts::DumpDotAll)
Function.dumpGraphForPass(PassIdName);