[all-commits] [llvm/llvm-project] 52cf07: [BOLT][NFC] Log through JournalingStreams (#81524)
Amir Ayupov via All-commits
all-commits at lists.llvm.org
Mon Feb 12 14:54:04 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 52cf07116bf0a8cab87b0f55176d198bcaa02575
https://github.com/llvm/llvm-project/commit/52cf07116bf0a8cab87b0f55176d198bcaa02575
Author: Amir Ayupov <aaupov at fb.com>
Date: 2024-02-12 (Mon, 12 Feb 2024)
Changed paths:
M bolt/include/bolt/Core/BinaryContext.h
M bolt/include/bolt/Core/DIEBuilder.h
M bolt/include/bolt/Core/DynoStats.h
M bolt/include/bolt/Core/Exceptions.h
M bolt/include/bolt/Passes/BinaryPasses.h
M bolt/include/bolt/Passes/CMOVConversion.h
M bolt/include/bolt/Passes/CacheMetrics.h
M bolt/include/bolt/Passes/ReorderData.h
M bolt/include/bolt/Passes/ReorderFunctions.h
M bolt/include/bolt/Passes/ShrinkWrapping.h
M bolt/include/bolt/Profile/BoltAddressTranslation.h
M bolt/include/bolt/Rewrite/RewriteInstance.h
M bolt/lib/Core/BinaryBasicBlock.cpp
M bolt/lib/Core/BinaryContext.cpp
M bolt/lib/Core/BinaryEmitter.cpp
M bolt/lib/Core/BinaryFunction.cpp
M bolt/lib/Core/DIEBuilder.cpp
M bolt/lib/Core/DebugData.cpp
M bolt/lib/Core/DynoStats.cpp
M bolt/lib/Core/Exceptions.cpp
M bolt/lib/Core/ParallelUtilities.cpp
M bolt/lib/Passes/ADRRelaxationPass.cpp
M bolt/lib/Passes/AllocCombiner.cpp
M bolt/lib/Passes/AsmDump.cpp
M bolt/lib/Passes/BinaryFunctionCallGraph.cpp
M bolt/lib/Passes/BinaryPasses.cpp
M bolt/lib/Passes/CMOVConversion.cpp
M bolt/lib/Passes/CacheMetrics.cpp
M bolt/lib/Passes/FrameAnalysis.cpp
M bolt/lib/Passes/FrameOptimizer.cpp
M bolt/lib/Passes/IdenticalCodeFolding.cpp
M bolt/lib/Passes/IndirectCallPromotion.cpp
M bolt/lib/Passes/Inliner.cpp
M bolt/lib/Passes/Instrumentation.cpp
M bolt/lib/Passes/JTFootprintReduction.cpp
M bolt/lib/Passes/LongJmp.cpp
M bolt/lib/Passes/LoopInversionPass.cpp
M bolt/lib/Passes/PLTCall.cpp
M bolt/lib/Passes/PatchEntries.cpp
M bolt/lib/Passes/RegAnalysis.cpp
M bolt/lib/Passes/RegReAssign.cpp
M bolt/lib/Passes/ReorderData.cpp
M bolt/lib/Passes/ReorderFunctions.cpp
M bolt/lib/Passes/RetpolineInsertion.cpp
M bolt/lib/Passes/ShrinkWrapping.cpp
M bolt/lib/Passes/SplitFunctions.cpp
M bolt/lib/Passes/StokeInfo.cpp
M bolt/lib/Passes/TailDuplication.cpp
M bolt/lib/Passes/ThreeWayBranch.cpp
M bolt/lib/Passes/ValidateInternalCalls.cpp
M bolt/lib/Passes/ValidateMemRefs.cpp
M bolt/lib/Passes/VeneerElimination.cpp
M bolt/lib/Profile/BoltAddressTranslation.cpp
M bolt/lib/Rewrite/BinaryPassManager.cpp
M bolt/lib/Rewrite/BoltDiff.cpp
M bolt/lib/Rewrite/DWARFRewriter.cpp
M bolt/lib/Rewrite/MachORewriteInstance.cpp
M bolt/lib/Rewrite/RewriteInstance.cpp
M bolt/lib/Target/X86/X86MCSymbolizer.cpp
A bolt/test/X86/fatal-error.s
A bolt/test/X86/log.test
M bolt/tools/bat-dump/bat-dump.cpp
M bolt/tools/driver/llvm-bolt.cpp
M bolt/unittests/Core/BinaryContext.cpp
M bolt/unittests/Core/MCPlusBuilder.cpp
Log Message:
-----------
[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 at fb.com>
Test Plan: NFC
More information about the All-commits
mailing list