[all-commits] [llvm/llvm-project] c1781b: [BOLT][NFC] Refactor logging and error handling
Rafael Auler via All-commits
all-commits at lists.llvm.org
Fri Feb 9 19:53:59 PST 2024
Branch: refs/heads/users/rafaelauler/bolt-logging-pr
Home: https://github.com/llvm/llvm-project
Commit: c1781b770d1400b62b3c324157a7895c1b9bdaaa
https://github.com/llvm/llvm-project/commit/c1781b770d1400b62b3c324157a7895c1b9bdaaa
Author: Rafael Auler <rafaelauler at fb.com>
Date: 2024-02-09 (Fri, 09 Feb 2024)
Changed paths:
M bolt/include/bolt/Core/BinaryContext.h
M bolt/include/bolt/Core/BinaryFunction.h
M bolt/include/bolt/Core/BinarySection.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/ADRRelaxationPass.h
M bolt/include/bolt/Passes/Aligner.h
M bolt/include/bolt/Passes/AllocCombiner.h
M bolt/include/bolt/Passes/AsmDump.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/FixRISCVCallsPass.h
M bolt/include/bolt/Passes/FixRelaxationPass.h
M bolt/include/bolt/Passes/FrameOptimizer.h
M bolt/include/bolt/Passes/Hugify.h
M bolt/include/bolt/Passes/IdenticalCodeFolding.h
M bolt/include/bolt/Passes/IndirectCallPromotion.h
M bolt/include/bolt/Passes/Inliner.h
M bolt/include/bolt/Passes/Instrumentation.h
M bolt/include/bolt/Passes/JTFootprintReduction.h
M bolt/include/bolt/Passes/LongJmp.h
M bolt/include/bolt/Passes/LoopInversionPass.h
M bolt/include/bolt/Passes/PLTCall.h
M bolt/include/bolt/Passes/PatchEntries.h
M bolt/include/bolt/Passes/RegReAssign.h
M bolt/include/bolt/Passes/ReorderData.h
M bolt/include/bolt/Passes/ReorderFunctions.h
M bolt/include/bolt/Passes/RetpolineInsertion.h
M bolt/include/bolt/Passes/ShrinkWrapping.h
M bolt/include/bolt/Passes/SplitFunctions.h
M bolt/include/bolt/Passes/StokeInfo.h
M bolt/include/bolt/Passes/TailDuplication.h
M bolt/include/bolt/Passes/ThreeWayBranch.h
M bolt/include/bolt/Passes/ValidateInternalCalls.h
M bolt/include/bolt/Passes/ValidateMemRefs.h
M bolt/include/bolt/Passes/VeneerElimination.h
M bolt/include/bolt/Profile/BoltAddressTranslation.h
M bolt/include/bolt/Rewrite/BinaryPassManager.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/BinarySection.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/Aligner.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/FixRISCVCallsPass.cpp
M bolt/lib/Passes/FixRelaxationPass.cpp
M bolt/lib/Passes/FrameAnalysis.cpp
M bolt/lib/Passes/FrameOptimizer.cpp
M bolt/lib/Passes/Hugify.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
M bolt/lib/Target/X86/X86MCSymbolizer.h
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] Refactor logging and error handling
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.
We also refactor old error handling code that would directly call
exit(1) inside BOLT libraries whenever a serious problem occurred. To
overcome this, we add a new class BOLTError and auxiliary functions
createFatalBOLTError() and createNonFatalBOLTError() that allows BOLT
libs to bubble up the problem to the caller by using the Error class
as a return type (or Expected). 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.
More information about the All-commits
mailing list