From a34c753fe709a624f5b087397fb05adeac2311e4 Mon Sep 17 00:00:00 2001 From: Rafael Auler Date: Fri, 8 Oct 2021 11:47:10 -0700 Subject: [PATCH] Rebase: [NFC] Refactor sources to be buildable in shared mode Summary: Moves source files into separate components, and make explicit component dependency on each other, so LLVM build system knows how to build BOLT in BUILD_SHARED_LIBS=ON. Please use the -c merge.renamelimit=230 git option when rebasing your work on top of this change. To achieve this, we create a new library to hold core IR files (most classes beginning with Binary in their names), a new library to hold Utils, some command line options shared across both RewriteInstance and core IR files, a new library called Rewrite to hold most classes concerned with running top-level functions coordinating the binary rewriting process, and a new library called Profile to hold classes dealing with profile reading and writing. To remove the dependency from BinaryContext into X86-specific classes, we do some refactoring on the BinaryContext constructor to receive a reference to the specific backend directly from RewriteInstance. Then, the dependency on X86 or AArch64-specific classes is transfered to the Rewrite library. We can't have the Core library depend on targets because targets depend on Core (which would create a cycle). Files implementing the entry point of a tool are transferred to the tools/ folder. All header files are transferred to the include/ folder. The src/ folder was renamed to lib/. (cherry picked from FBD32746834) --- bolt/CMakeLists.txt | 5 +- .../bolt/Core}/BinaryBasicBlock.h | 0 .../bolt/Core}/BinaryContext.h | 19 +- bolt/{src => include/bolt/Core}/BinaryData.h | 0 .../bolt/Core}/BinaryEmitter.h | 0 .../bolt/Core}/BinaryFunction.h | 16 +- bolt/{src => include/bolt/Core}/BinaryLoop.h | 0 .../bolt/Core}/BinarySection.h | 4 +- bolt/{src => include/bolt/Core}/DebugData.h | 0 bolt/{src => include/bolt/Core}/DynoStats.h | 0 bolt/{src => include/bolt/Core}/Exceptions.h | 0 bolt/{src => include/bolt/Core}/JumpTable.h | 2 +- bolt/{src => include/bolt/Core}/MCPlus.h | 0 .../bolt/Core}/MCPlusBuilder.h | 4 +- .../bolt/Core}/ParallelUtilities.h | 4 +- bolt/{src => include/bolt/Core}/Relocation.h | 0 .../bolt}/Passes/ADRRelaxationPass.h | 2 +- bolt/{src => include/bolt}/Passes/Aligner.h | 2 +- .../bolt}/Passes/AllocCombiner.h | 2 +- .../bolt}/Passes/BinaryFunctionCallGraph.h | 7 +- .../bolt}/Passes/BinaryPasses.h | 6 +- .../bolt/Passes}/CacheMetrics.h | 0 bolt/{src => include/bolt}/Passes/CallGraph.h | 0 .../bolt}/Passes/CallGraphWalker.h | 0 .../bolt}/Passes/DataflowAnalysis.h | 4 +- .../bolt}/Passes/DataflowInfoManager.h | 14 +- .../bolt}/Passes/DominatorAnalysis.h | 2 +- .../bolt}/Passes/FrameAnalysis.h | 2 +- .../bolt}/Passes/FrameOptimizer.h | 2 +- bolt/{src => include/bolt}/Passes/HFSort.h | 2 +- .../bolt}/Passes/IdenticalCodeFolding.h | 4 +- .../bolt}/Passes/IndirectCallPromotion.h | 2 +- bolt/{src => include/bolt}/Passes/Inliner.h | 2 +- .../bolt}/Passes/Instrumentation.h | 4 +- .../bolt}/Passes/InstrumentationSummary.h | 0 .../bolt}/Passes/JTFootprintReduction.h | 2 +- .../bolt}/Passes/LivenessAnalysis.h | 4 +- bolt/{src => include/bolt}/Passes/LongJmp.h | 2 +- .../bolt}/Passes/LoopInversionPass.h | 2 +- bolt/{src => include/bolt}/Passes/MCF.h | 0 bolt/{src => include/bolt}/Passes/PLTCall.h | 2 +- .../bolt}/Passes/PatchEntries.h | 4 +- .../bolt}/Passes/ReachingDefOrUse.h | 4 +- .../bolt}/Passes/ReachingInsns.h | 2 +- .../bolt}/Passes/RegAnalysis.h | 0 .../bolt}/Passes/RegReAssign.h | 4 +- .../bolt}/Passes/ReorderAlgorithm.h | 4 +- .../bolt}/Passes/ReorderData.h | 2 +- .../bolt}/Passes/ReorderFunctions.h | 4 +- .../bolt}/Passes/ReorderUtils.h | 0 .../bolt}/Passes/RetpolineInsertion.h | 2 +- .../bolt}/Passes/ShrinkWrapping.h | 2 +- .../bolt}/Passes/SplitFunctions.h | 2 +- .../bolt}/Passes/StackAllocationAnalysis.h | 2 +- .../bolt}/Passes/StackAvailableExpressions.h | 2 +- .../bolt}/Passes/StackPointerTracking.h | 2 +- .../bolt}/Passes/StackReachingUses.h | 2 +- bolt/{src => include/bolt}/Passes/StokeInfo.h | 2 +- .../bolt}/Passes/TailDuplication.h | 2 +- .../bolt}/Passes/ThreeWayBranch.h | 2 +- .../bolt}/Passes/ValidateInternalCalls.h | 2 +- .../bolt}/Passes/VeneerElimination.h | 2 +- .../bolt/Profile}/BoltAddressTranslation.h | 0 .../bolt/Profile}/DataAggregator.h | 2 +- .../bolt/Profile}/DataReader.h | 2 +- bolt/{src => include/bolt/Profile}/Heatmap.h | 0 .../bolt/Profile}/ProfileReaderBase.h | 0 .../bolt/Profile}/ProfileYAMLMapping.h | 2 +- .../bolt/Profile}/YAMLProfileReader.h | 4 +- .../bolt/Profile}/YAMLProfileWriter.h | 0 .../bolt/Rewrite}/BinaryPassManager.h | 2 +- .../bolt/Rewrite}/DWARFRewriter.h | 4 +- .../Rewrite}/ExecutableFileMemoryManager.h | 0 .../bolt/Rewrite}/MachORewriteInstance.h | 2 +- .../bolt/Rewrite}/RewriteInstance.h | 4 +- .../bolt}/RuntimeLibs/HugifyRuntimeLibrary.h | 2 +- .../InstrumentationRuntimeLibrary.h | 4 +- .../bolt}/RuntimeLibs/RuntimeLibrary.h | 0 bolt/include/bolt/Utils/CommandLineOpts.h | 82 +++++++ .../bolt/Utils}/NameResolver.h | 0 .../bolt/Utils}/NameShortener.h | 0 bolt/{src => include/bolt/Utils}/Utils.h | 0 bolt/lib/CMakeLists.txt | 7 + bolt/{src => lib/Core}/BinaryBasicBlock.cpp | 6 +- bolt/{src => lib/Core}/BinaryContext.cpp | 61 +---- bolt/{src => lib/Core}/BinaryData.cpp | 4 +- bolt/{src => lib/Core}/BinaryEmitter.cpp | 20 +- bolt/{src => lib/Core}/BinaryFunction.cpp | 14 +- .../Core}/BinaryFunctionProfile.cpp | 49 +--- bolt/{src => lib/Core}/BinarySection.cpp | 6 +- bolt/lib/Core/CMakeLists.txt | 27 ++ bolt/{src => lib/Core}/DebugData.cpp | 9 +- bolt/{src => lib/Core}/DynoStats.cpp | 7 +- bolt/{src => lib/Core}/Exceptions.cpp | 4 +- bolt/{src => lib/Core}/JumpTable.cpp | 6 +- bolt/{src => lib/Core}/MCPlusBuilder.cpp | 6 +- bolt/{src => lib/Core}/ParallelUtilities.cpp | 8 +- bolt/{src => lib/Core}/Relocation.cpp | 2 +- .../{src => lib}/Passes/ADRRelaxationPass.cpp | 4 +- bolt/{src => lib}/Passes/Aligner.cpp | 4 +- bolt/{src => lib}/Passes/AllocCombiner.cpp | 2 +- .../Passes/BinaryFunctionCallGraph.cpp | 6 +- bolt/{src => lib}/Passes/BinaryPasses.cpp | 39 +-- bolt/{src => lib}/Passes/CMakeLists.txt | 13 +- bolt/{src => lib/Passes}/CacheMetrics.cpp | 6 +- bolt/{src => lib}/Passes/CallGraph.cpp | 2 +- bolt/{src => lib}/Passes/CallGraphWalker.cpp | 4 +- bolt/{src => lib}/Passes/DataflowAnalysis.cpp | 2 +- .../Passes/DataflowInfoManager.cpp | 3 +- .../Passes/ExtTSPReorderAlgorithm.cpp | 6 +- bolt/{src => lib}/Passes/FrameAnalysis.cpp | 8 +- bolt/{src => lib}/Passes/FrameOptimizer.cpp | 14 +- bolt/{src => lib}/Passes/HFSort.cpp | 2 +- bolt/{src => lib}/Passes/HFSortPlus.cpp | 2 +- .../Passes/IdenticalCodeFolding.cpp | 4 +- .../Passes/IndirectCallPromotion.cpp | 20 +- bolt/{src => lib}/Passes/Inliner.cpp | 4 +- bolt/{src => lib}/Passes/Instrumentation.cpp | 8 +- .../Passes/JTFootprintReduction.cpp | 6 +- bolt/{src => lib}/Passes/LivenessAnalysis.cpp | 2 +- bolt/{src => lib}/Passes/LongJmp.cpp | 2 +- .../{src => lib}/Passes/LoopInversionPass.cpp | 4 +- bolt/{src => lib}/Passes/MCF.cpp | 6 +- bolt/{src => lib}/Passes/PLTCall.cpp | 2 +- bolt/{src => lib}/Passes/PatchEntries.cpp | 4 +- bolt/{src => lib}/Passes/PettisAndHansen.cpp | 2 +- bolt/{src => lib}/Passes/RegAnalysis.cpp | 6 +- bolt/{src => lib}/Passes/RegReAssign.cpp | 12 +- bolt/{src => lib}/Passes/ReorderAlgorithm.cpp | 6 +- bolt/{src => lib}/Passes/ReorderData.cpp | 2 +- bolt/{src => lib}/Passes/ReorderFunctions.cpp | 4 +- .../Passes/RetpolineInsertion.cpp | 2 +- bolt/{src => lib}/Passes/ShrinkWrapping.cpp | 6 +- bolt/{src => lib}/Passes/SplitFunctions.cpp | 6 +- .../Passes/StackAllocationAnalysis.cpp | 4 +- .../Passes/StackAvailableExpressions.cpp | 6 +- .../Passes/StackPointerTracking.cpp | 2 +- .../{src => lib}/Passes/StackReachingUses.cpp | 4 +- bolt/{src => lib}/Passes/StokeInfo.cpp | 6 +- bolt/{src => lib}/Passes/TailDuplication.cpp | 2 +- bolt/{src => lib}/Passes/ThreeWayBranch.cpp | 2 +- .../Passes/ValidateInternalCalls.cpp | 6 +- .../{src => lib}/Passes/VeneerElimination.cpp | 2 +- .../Profile}/BoltAddressTranslation.cpp | 4 +- bolt/lib/Profile/CMakeLists.txt | 15 ++ bolt/{src => lib/Profile}/DataAggregator.cpp | 49 +--- bolt/{src => lib/Profile}/DataReader.cpp | 8 +- bolt/{src => lib/Profile}/Heatmap.cpp | 16 +- .../Profile}/ProfileReaderBase.cpp | 2 +- .../Profile}/YAMLProfileReader.cpp | 12 +- .../Profile}/YAMLProfileWriter.cpp | 12 +- .../Rewrite}/BinaryPassManager.cpp | 62 ++--- bolt/{src => lib/Rewrite}/BoltDiff.cpp | 6 +- bolt/lib/Rewrite/CMakeLists.txt | 45 ++++ bolt/{src => lib/Rewrite}/DWARFRewriter.cpp | 12 +- .../Rewrite}/ExecutableFileMemoryManager.cpp | 4 +- .../Rewrite}/MachORewriteInstance.cpp | 55 ++++- bolt/{src => lib/Rewrite}/RewriteInstance.cpp | 227 ++++------------- bolt/{src => lib}/RuntimeLibs/CMakeLists.txt | 16 +- .../RuntimeLibs/HugifyRuntimeLibrary.cpp | 4 +- .../InstrumentationRuntimeLibrary.cpp | 22 +- .../RuntimeLibs/RuntimeLibrary.cpp | 4 +- .../Target/AArch64/AArch64MCPlusBuilder.cpp | 3 +- .../Target/AArch64/CMakeLists.txt | 9 +- bolt/{src => lib}/Target/CMakeLists.txt | 0 bolt/{src => lib}/Target/X86/CMakeLists.txt | 9 +- .../Target/X86/X86MCPlusBuilder.cpp | 4 +- bolt/lib/Utils/CMakeLists.txt | 53 ++++ bolt/lib/Utils/CommandLineOpts.cpp | 232 ++++++++++++++++++ bolt/{src => lib/Utils}/Utils.cpp | 3 +- bolt/src/CMakeLists.txt | 124 ---------- bolt/tools/CMakeLists.txt | 2 + bolt/tools/driver/CMakeLists.txt | 22 ++ bolt/{src => tools/driver}/llvm-bolt.cpp | 62 +---- .../{src => tools}/merge-fdata/CMakeLists.txt | 0 .../merge-fdata/merge-fdata.cpp | 4 +- 176 files changed, 993 insertions(+), 885 deletions(-) rename bolt/{src => include/bolt/Core}/BinaryBasicBlock.h (100%) rename bolt/{src => include/bolt/Core}/BinaryContext.h (99%) rename bolt/{src => include/bolt/Core}/BinaryData.h (100%) rename bolt/{src => include/bolt/Core}/BinaryEmitter.h (100%) rename bolt/{src => include/bolt/Core}/BinaryFunction.h (99%) rename bolt/{src => include/bolt/Core}/BinaryLoop.h (100%) rename bolt/{src => include/bolt/Core}/BinarySection.h (99%) rename bolt/{src => include/bolt/Core}/DebugData.h (100%) rename bolt/{src => include/bolt/Core}/DynoStats.h (100%) rename bolt/{src => include/bolt/Core}/Exceptions.h (100%) rename bolt/{src => include/bolt/Core}/JumpTable.h (99%) rename bolt/{src => include/bolt/Core}/MCPlus.h (100%) rename bolt/{src => include/bolt/Core}/MCPlusBuilder.h (99%) rename bolt/{src => include/bolt/Core}/ParallelUtilities.h (98%) rename bolt/{src => include/bolt/Core}/Relocation.h (100%) rename bolt/{src => include/bolt}/Passes/ADRRelaxationPass.h (97%) rename bolt/{src => include/bolt}/Passes/Aligner.h (97%) rename bolt/{src => include/bolt}/Passes/AllocCombiner.h (97%) rename bolt/{src => include/bolt}/Passes/BinaryFunctionCallGraph.h (98%) rename bolt/{src => include/bolt}/Passes/BinaryPasses.h (99%) rename bolt/{src => include/bolt/Passes}/CacheMetrics.h (100%) rename bolt/{src => include/bolt}/Passes/CallGraph.h (100%) rename bolt/{src => include/bolt}/Passes/CallGraphWalker.h (100%) rename bolt/{src => include/bolt}/Passes/DataflowAnalysis.h (99%) rename bolt/{src => include/bolt}/Passes/DataflowInfoManager.h (91%) rename bolt/{src => include/bolt}/Passes/DominatorAnalysis.h (99%) rename bolt/{src => include/bolt}/Passes/FrameAnalysis.h (99%) rename bolt/{src => include/bolt}/Passes/FrameOptimizer.h (99%) rename bolt/{src => include/bolt}/Passes/HFSort.h (99%) rename bolt/{src => include/bolt}/Passes/IdenticalCodeFolding.h (94%) rename bolt/{src => include/bolt}/Passes/IndirectCallPromotion.h (99%) rename bolt/{src => include/bolt}/Passes/Inliner.h (98%) rename bolt/{src => include/bolt}/Passes/Instrumentation.h (98%) rename bolt/{src => include/bolt}/Passes/InstrumentationSummary.h (100%) rename bolt/{src => include/bolt}/Passes/JTFootprintReduction.h (98%) rename bolt/{src => include/bolt}/Passes/LivenessAnalysis.h (98%) rename bolt/{src => include/bolt}/Passes/LongJmp.h (99%) rename bolt/{src => include/bolt}/Passes/LoopInversionPass.h (97%) rename bolt/{src => include/bolt}/Passes/MCF.h (100%) rename bolt/{src => include/bolt}/Passes/PLTCall.h (96%) rename bolt/{src => include/bolt}/Passes/PatchEntries.h (90%) rename bolt/{src => include/bolt}/Passes/ReachingDefOrUse.h (98%) rename bolt/{src => include/bolt}/Passes/ReachingInsns.h (98%) rename bolt/{src => include/bolt}/Passes/RegAnalysis.h (100%) rename bolt/{src => include/bolt}/Passes/RegReAssign.h (96%) rename bolt/{src => include/bolt}/Passes/ReorderAlgorithm.h (99%) rename bolt/{src => include/bolt}/Passes/ReorderData.h (98%) rename bolt/{src => include/bolt}/Passes/ReorderFunctions.h (93%) rename bolt/{src => include/bolt}/Passes/ReorderUtils.h (100%) rename bolt/{src => include/bolt}/Passes/RetpolineInsertion.h (98%) rename bolt/{src => include/bolt}/Passes/ShrinkWrapping.h (99%) rename bolt/{src => include/bolt}/Passes/SplitFunctions.h (97%) rename bolt/{src => include/bolt}/Passes/StackAllocationAnalysis.h (98%) rename bolt/{src => include/bolt}/Passes/StackAvailableExpressions.h (97%) rename bolt/{src => include/bolt}/Passes/StackPointerTracking.h (99%) rename bolt/{src => include/bolt}/Passes/StackReachingUses.h (98%) rename bolt/{src => include/bolt}/Passes/StokeInfo.h (99%) rename bolt/{src => include/bolt}/Passes/TailDuplication.h (99%) rename bolt/{src => include/bolt}/Passes/ThreeWayBranch.h (97%) rename bolt/{src => include/bolt}/Passes/ValidateInternalCalls.h (99%) rename bolt/{src => include/bolt}/Passes/VeneerElimination.h (96%) rename bolt/{src => include/bolt/Profile}/BoltAddressTranslation.h (100%) rename bolt/{src => include/bolt/Profile}/DataAggregator.h (99%) rename bolt/{src => include/bolt/Profile}/DataReader.h (99%) rename bolt/{src => include/bolt/Profile}/Heatmap.h (100%) rename bolt/{src => include/bolt/Profile}/ProfileReaderBase.h (100%) rename bolt/{src => include/bolt/Profile}/ProfileYAMLMapping.h (99%) rename bolt/{src => include/bolt/Profile}/YAMLProfileReader.h (97%) rename bolt/{src => include/bolt/Profile}/YAMLProfileWriter.h (100%) rename bolt/{src => include/bolt/Rewrite}/BinaryPassManager.h (97%) rename bolt/{src => include/bolt/Rewrite}/DWARFRewriter.h (99%) rename bolt/{src => include/bolt/Rewrite}/ExecutableFileMemoryManager.h (100%) rename bolt/{src => include/bolt/Rewrite}/MachORewriteInstance.h (98%) rename bolt/{src => include/bolt/Rewrite}/RewriteInstance.h (99%) rename bolt/{src => include/bolt}/RuntimeLibs/HugifyRuntimeLibrary.h (96%) rename bolt/{src => include/bolt}/RuntimeLibs/InstrumentationRuntimeLibrary.h (94%) rename bolt/{src => include/bolt}/RuntimeLibs/RuntimeLibrary.h (100%) create mode 100644 bolt/include/bolt/Utils/CommandLineOpts.h rename bolt/{src => include/bolt/Utils}/NameResolver.h (100%) rename bolt/{src => include/bolt/Utils}/NameShortener.h (100%) rename bolt/{src => include/bolt/Utils}/Utils.h (100%) create mode 100644 bolt/lib/CMakeLists.txt rename bolt/{src => lib/Core}/BinaryBasicBlock.cpp (99%) rename bolt/{src => lib/Core}/BinaryContext.cpp (97%) rename bolt/{src => lib/Core}/BinaryData.cpp (98%) rename bolt/{src => lib/Core}/BinaryEmitter.cpp (98%) rename bolt/{src => lib/Core}/BinaryFunction.cpp (99%) rename bolt/{src => lib/Core}/BinaryFunctionProfile.cpp (90%) rename bolt/{src => lib/Core}/BinarySection.cpp (99%) create mode 100644 bolt/lib/Core/CMakeLists.txt rename bolt/{src => lib/Core}/DebugData.cpp (99%) rename bolt/{src => lib/Core}/DynoStats.cpp (99%) rename bolt/{src => lib/Core}/Exceptions.cpp (99%) rename bolt/{src => lib/Core}/JumpTable.cpp (97%) rename bolt/{src => lib/Core}/MCPlusBuilder.cpp (99%) rename bolt/{src => lib/Core}/ParallelUtilities.cpp (98%) rename bolt/{src => lib/Core}/Relocation.cpp (99%) rename bolt/{src => lib}/Passes/ADRRelaxationPass.cpp (96%) rename bolt/{src => lib}/Passes/Aligner.cpp (98%) rename bolt/{src => lib}/Passes/AllocCombiner.cpp (98%) rename bolt/{src => lib}/Passes/BinaryFunctionCallGraph.cpp (98%) rename bolt/{src => lib}/Passes/BinaryPasses.cpp (98%) rename bolt/{src => lib}/Passes/CMakeLists.txt (89%) rename bolt/{src => lib/Passes}/CacheMetrics.cpp (99%) rename bolt/{src => lib}/Passes/CallGraph.cpp (99%) rename bolt/{src => lib}/Passes/CallGraphWalker.cpp (94%) rename bolt/{src => lib}/Passes/DataflowAnalysis.cpp (98%) rename bolt/{src => lib}/Passes/DataflowInfoManager.cpp (98%) rename bolt/{src => lib}/Passes/ExtTSPReorderAlgorithm.cpp (99%) rename bolt/{src => lib}/Passes/FrameAnalysis.cpp (99%) rename bolt/{src => lib}/Passes/FrameOptimizer.cpp (97%) rename bolt/{src => lib}/Passes/HFSort.cpp (99%) rename bolt/{src => lib}/Passes/HFSortPlus.cpp (99%) rename bolt/{src => lib}/Passes/IdenticalCodeFolding.cpp (99%) rename bolt/{src => lib}/Passes/IndirectCallPromotion.cpp (98%) rename bolt/{src => lib}/Passes/Inliner.cpp (99%) rename bolt/{src => lib}/Passes/Instrumentation.cpp (99%) rename bolt/{src => lib}/Passes/JTFootprintReduction.cpp (98%) rename bolt/{src => lib}/Passes/LivenessAnalysis.cpp (93%) rename bolt/{src => lib}/Passes/LongJmp.cpp (99%) rename bolt/{src => lib}/Passes/LoopInversionPass.cpp (97%) rename bolt/{src => lib}/Passes/MCF.cpp (99%) rename bolt/{src => lib}/Passes/PLTCall.cpp (98%) rename bolt/{src => lib}/Passes/PatchEntries.cpp (98%) rename bolt/{src => lib}/Passes/PettisAndHansen.cpp (99%) rename bolt/{src => lib}/Passes/RegAnalysis.cpp (98%) rename bolt/{src => lib}/Passes/RegReAssign.cpp (98%) rename bolt/{src => lib}/Passes/ReorderAlgorithm.cpp (99%) rename bolt/{src => lib}/Passes/ReorderData.cpp (99%) rename bolt/{src => lib}/Passes/ReorderFunctions.cpp (99%) rename bolt/{src => lib}/Passes/RetpolineInsertion.cpp (99%) rename bolt/{src => lib}/Passes/ShrinkWrapping.cpp (99%) rename bolt/{src => lib}/Passes/SplitFunctions.cpp (98%) rename bolt/{src => lib}/Passes/StackAllocationAnalysis.cpp (98%) rename bolt/{src => lib}/Passes/StackAvailableExpressions.cpp (97%) rename bolt/{src => lib}/Passes/StackPointerTracking.cpp (95%) rename bolt/{src => lib}/Passes/StackReachingUses.cpp (98%) rename bolt/{src => lib}/Passes/StokeInfo.cpp (97%) rename bolt/{src => lib}/Passes/TailDuplication.cpp (99%) rename bolt/{src => lib}/Passes/ThreeWayBranch.cpp (99%) rename bolt/{src => lib}/Passes/ValidateInternalCalls.cpp (98%) rename bolt/{src => lib}/Passes/VeneerElimination.cpp (98%) rename bolt/{src => lib/Profile}/BoltAddressTranslation.cpp (99%) create mode 100644 bolt/lib/Profile/CMakeLists.txt rename bolt/{src => lib/Profile}/DataAggregator.cpp (98%) rename bolt/{src => lib/Profile}/DataReader.cpp (99%) rename bolt/{src => lib/Profile}/Heatmap.cpp (96%) rename bolt/{src => lib/Profile}/ProfileReaderBase.cpp (93%) rename bolt/{src => lib/Profile}/YAMLProfileReader.cpp (98%) rename bolt/{src => lib/Profile}/YAMLProfileWriter.cpp (96%) rename bolt/{src => lib/Rewrite}/BinaryPassManager.cpp (93%) rename bolt/{src => lib/Rewrite}/BoltDiff.cpp (99%) create mode 100644 bolt/lib/Rewrite/CMakeLists.txt rename bolt/{src => lib/Rewrite}/DWARFRewriter.cpp (99%) rename bolt/{src => lib/Rewrite}/ExecutableFileMemoryManager.cpp (97%) rename bolt/{src => lib/Rewrite}/MachORewriteInstance.cpp (92%) rename bolt/{src => lib/Rewrite}/RewriteInstance.cpp (97%) rename bolt/{src => lib}/RuntimeLibs/CMakeLists.txt (51%) rename bolt/{src => lib}/RuntimeLibs/HugifyRuntimeLibrary.cpp (97%) rename bolt/{src => lib}/RuntimeLibs/InstrumentationRuntimeLibrary.cpp (97%) rename bolt/{src => lib}/RuntimeLibs/RuntimeLibrary.cpp (97%) rename bolt/{src => lib}/Target/AArch64/AArch64MCPlusBuilder.cpp (99%) rename bolt/{src => lib}/Target/AArch64/CMakeLists.txt (70%) rename bolt/{src => lib}/Target/CMakeLists.txt (100%) rename bolt/{src => lib}/Target/X86/CMakeLists.txt (68%) rename bolt/{src => lib}/Target/X86/X86MCPlusBuilder.cpp (99%) create mode 100644 bolt/lib/Utils/CMakeLists.txt create mode 100644 bolt/lib/Utils/CommandLineOpts.cpp rename bolt/{src => lib/Utils}/Utils.cpp (98%) delete mode 100644 bolt/src/CMakeLists.txt create mode 100644 bolt/tools/CMakeLists.txt create mode 100644 bolt/tools/driver/CMakeLists.txt rename bolt/{src => tools/driver}/llvm-bolt.cpp (87%) rename bolt/{src => tools}/merge-fdata/CMakeLists.txt (100%) rename bolt/{src => tools}/merge-fdata/merge-fdata.cpp (99%) diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt index 4f5664d7abc6..f43539b8e475 100644 --- a/bolt/CMakeLists.txt +++ b/bolt/CMakeLists.txt @@ -18,6 +18,8 @@ ExternalProject_Add(bolt_rt BUILD_ALWAYS True ) +include_directories( ${BOLT_SOURCE_DIR}/include ) + install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)" COMPONENT bolt_rt) @@ -25,5 +27,6 @@ add_llvm_install_targets(install-bolt_rt DEPENDS bolt_rt COMPONENT bolt_rt) -add_subdirectory(src) +add_subdirectory(lib) add_subdirectory(test) +add_subdirectory(tools) diff --git a/bolt/src/BinaryBasicBlock.h b/bolt/include/bolt/Core/BinaryBasicBlock.h similarity index 100% rename from bolt/src/BinaryBasicBlock.h rename to bolt/include/bolt/Core/BinaryBasicBlock.h diff --git a/bolt/src/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h similarity index 99% rename from bolt/src/BinaryContext.h rename to bolt/include/bolt/Core/BinaryContext.h index 3ca52693d7be..e1603793e6b7 100644 --- a/bolt/src/BinaryContext.h +++ b/bolt/include/bolt/Core/BinaryContext.h @@ -13,12 +13,12 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_BINARY_CONTEXT_H #define LLVM_TOOLS_LLVM_BOLT_BINARY_CONTEXT_H -#include "BinaryData.h" -#include "BinarySection.h" -#include "DebugData.h" -#include "JumpTable.h" -#include "MCPlusBuilder.h" -#include "RuntimeLibs/RuntimeLibrary.h" +#include "bolt/Core/BinaryData.h" +#include "bolt/Core/BinarySection.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/RuntimeLibs/RuntimeLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Triple.h" @@ -36,8 +36,8 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/TargetRegistry.h" #include "llvm/Support/ErrorOr.h" -#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -221,6 +221,11 @@ public: /// overwritten, but it is okay to re-generate debug info for them. std::set ProcessedCUs; + // Setup MCPlus target builder + void initializeTarget(std::unique_ptr TargetBuilder) { + MIB = std::move(TargetBuilder); + } + /// Given DWOId returns CU if it exists in DWOCUs. Optional getDWOCU(uint64_t DWOId); diff --git a/bolt/src/BinaryData.h b/bolt/include/bolt/Core/BinaryData.h similarity index 100% rename from bolt/src/BinaryData.h rename to bolt/include/bolt/Core/BinaryData.h diff --git a/bolt/src/BinaryEmitter.h b/bolt/include/bolt/Core/BinaryEmitter.h similarity index 100% rename from bolt/src/BinaryEmitter.h rename to bolt/include/bolt/Core/BinaryEmitter.h diff --git a/bolt/src/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h similarity index 99% rename from bolt/src/BinaryFunction.h rename to bolt/include/bolt/Core/BinaryFunction.h index a824f3d58883..60a080d07fa5 100644 --- a/bolt/src/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -14,14 +14,14 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_H #define LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_H -#include "BinaryBasicBlock.h" -#include "BinaryContext.h" -#include "BinaryLoop.h" -#include "BinarySection.h" -#include "DebugData.h" -#include "JumpTable.h" -#include "MCPlus.h" -#include "NameResolver.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryLoop.h" +#include "bolt/Core/BinarySection.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Core/MCPlus.h" +#include "bolt/Utils/NameResolver.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" #include "llvm/BinaryFormat/Dwarf.h" diff --git a/bolt/src/BinaryLoop.h b/bolt/include/bolt/Core/BinaryLoop.h similarity index 100% rename from bolt/src/BinaryLoop.h rename to bolt/include/bolt/Core/BinaryLoop.h diff --git a/bolt/src/BinarySection.h b/bolt/include/bolt/Core/BinarySection.h similarity index 99% rename from bolt/src/BinarySection.h rename to bolt/include/bolt/Core/BinarySection.h index acb4ba438331..2de6c8ab63cb 100644 --- a/bolt/src/BinarySection.h +++ b/bolt/include/bolt/Core/BinarySection.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_BINARY_SECTION_H #define LLVM_TOOLS_LLVM_BOLT_BINARY_SECTION_H -#include "DebugData.h" -#include "Relocation.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Core/Relocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/BinaryFormat/ELF.h" diff --git a/bolt/src/DebugData.h b/bolt/include/bolt/Core/DebugData.h similarity index 100% rename from bolt/src/DebugData.h rename to bolt/include/bolt/Core/DebugData.h diff --git a/bolt/src/DynoStats.h b/bolt/include/bolt/Core/DynoStats.h similarity index 100% rename from bolt/src/DynoStats.h rename to bolt/include/bolt/Core/DynoStats.h diff --git a/bolt/src/Exceptions.h b/bolt/include/bolt/Core/Exceptions.h similarity index 100% rename from bolt/src/Exceptions.h rename to bolt/include/bolt/Core/Exceptions.h diff --git a/bolt/src/JumpTable.h b/bolt/include/bolt/Core/JumpTable.h similarity index 99% rename from bolt/src/JumpTable.h rename to bolt/include/bolt/Core/JumpTable.h index 40619972c2fe..0fd6a9282a4c 100644 --- a/bolt/src/JumpTable.h +++ b/bolt/include/bolt/Core/JumpTable.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_JUMP_TABLE_H #define LLVM_TOOLS_LLVM_BOLT_JUMP_TABLE_H -#include "BinaryData.h" +#include "bolt/Core/BinaryData.h" #include #include diff --git a/bolt/src/MCPlus.h b/bolt/include/bolt/Core/MCPlus.h similarity index 100% rename from bolt/src/MCPlus.h rename to bolt/include/bolt/Core/MCPlus.h diff --git a/bolt/src/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h similarity index 99% rename from bolt/src/MCPlusBuilder.h rename to bolt/include/bolt/Core/MCPlusBuilder.h index 929fc8921660..af4b9f8a4989 100644 --- a/bolt/src/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -13,8 +13,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_MCPLUSBUILDER_H #define LLVM_TOOLS_LLVM_BOLT_MCPLUSBUILDER_H -#include "MCPlus.h" -#include "Relocation.h" +#include "bolt/Core/MCPlus.h" +#include "bolt/Core/Relocation.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/Optional.h" diff --git a/bolt/src/ParallelUtilities.h b/bolt/include/bolt/Core/ParallelUtilities.h similarity index 98% rename from bolt/src/ParallelUtilities.h rename to bolt/include/bolt/Core/ParallelUtilities.h index fe2e452dcfb8..eb6cfc3ec563 100644 --- a/bolt/src/ParallelUtilities.h +++ b/bolt/include/bolt/Core/ParallelUtilities.h @@ -1,4 +1,4 @@ -//===-- ParallelUtilities.h - ----------------------------------*- C++ -*-===// +//===-- ParallelUtilities.h - -----------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -15,7 +15,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PARALLEL_UTILITIES_H #define LLVM_TOOLS_LLVM_BOLT_PARALLEL_UTILITIES_H -#include "MCPlusBuilder.h" +#include "bolt/Core/MCPlusBuilder.h" #include "llvm/Support/CommandLine.h" using namespace llvm; diff --git a/bolt/src/Relocation.h b/bolt/include/bolt/Core/Relocation.h similarity index 100% rename from bolt/src/Relocation.h rename to bolt/include/bolt/Core/Relocation.h diff --git a/bolt/src/Passes/ADRRelaxationPass.h b/bolt/include/bolt/Passes/ADRRelaxationPass.h similarity index 97% rename from bolt/src/Passes/ADRRelaxationPass.h rename to bolt/include/bolt/Passes/ADRRelaxationPass.h index 49944a4a68b3..d39d883ff619 100644 --- a/bolt/src/Passes/ADRRelaxationPass.h +++ b/bolt/include/bolt/Passes/ADRRelaxationPass.h @@ -12,7 +12,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_ADRRELAXATIONPASS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_ADRRELAXATIONPASS_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" // This pass replaces AArch64 non-local ADR instructions // with ADRP + ADD due to small offset range of ADR instruction diff --git a/bolt/src/Passes/Aligner.h b/bolt/include/bolt/Passes/Aligner.h similarity index 97% rename from bolt/src/Passes/Aligner.h rename to bolt/include/bolt/Passes/Aligner.h index 4a2acbebbbc0..ca5e859d6f97 100644 --- a/bolt/src/Passes/Aligner.h +++ b/bolt/include/bolt/Passes/Aligner.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_ALIGNER_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_ALIGNER_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/AllocCombiner.h b/bolt/include/bolt/Passes/AllocCombiner.h similarity index 97% rename from bolt/src/Passes/AllocCombiner.h rename to bolt/include/bolt/Passes/AllocCombiner.h index d337ec7dfca5..22ba9cdf81bf 100644 --- a/bolt/src/Passes/AllocCombiner.h +++ b/bolt/include/bolt/Passes/AllocCombiner.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEDEFRAG_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEDEFRAG_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/BinaryFunctionCallGraph.h b/bolt/include/bolt/Passes/BinaryFunctionCallGraph.h similarity index 98% rename from bolt/src/Passes/BinaryFunctionCallGraph.h rename to bolt/include/bolt/Passes/BinaryFunctionCallGraph.h index 68019ccd05da..1bb5724f3dad 100644 --- a/bolt/src/Passes/BinaryFunctionCallGraph.h +++ b/bolt/include/bolt/Passes/BinaryFunctionCallGraph.h @@ -11,11 +11,10 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H -#include "CallGraph.h" - -#include -#include +#include "bolt/Passes/CallGraph.h" #include +#include +#include namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/BinaryPasses.h b/bolt/include/bolt/Passes/BinaryPasses.h similarity index 99% rename from bolt/src/Passes/BinaryPasses.h rename to bolt/include/bolt/Passes/BinaryPasses.h index d93024d83046..8fcf985058ed 100644 --- a/bolt/src/Passes/BinaryPasses.h +++ b/bolt/include/bolt/Passes/BinaryPasses.h @@ -13,9 +13,9 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_BINARY_PASSES_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_BINARY_PASSES_H -#include "BinaryContext.h" -#include "BinaryFunction.h" -#include "DynoStats.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/DynoStats.h" #include "llvm/Support/CommandLine.h" #include #include diff --git a/bolt/src/CacheMetrics.h b/bolt/include/bolt/Passes/CacheMetrics.h similarity index 100% rename from bolt/src/CacheMetrics.h rename to bolt/include/bolt/Passes/CacheMetrics.h diff --git a/bolt/src/Passes/CallGraph.h b/bolt/include/bolt/Passes/CallGraph.h similarity index 100% rename from bolt/src/Passes/CallGraph.h rename to bolt/include/bolt/Passes/CallGraph.h diff --git a/bolt/src/Passes/CallGraphWalker.h b/bolt/include/bolt/Passes/CallGraphWalker.h similarity index 100% rename from bolt/src/Passes/CallGraphWalker.h rename to bolt/include/bolt/Passes/CallGraphWalker.h diff --git a/bolt/src/Passes/DataflowAnalysis.h b/bolt/include/bolt/Passes/DataflowAnalysis.h similarity index 99% rename from bolt/src/Passes/DataflowAnalysis.h rename to bolt/include/bolt/Passes/DataflowAnalysis.h index 29c13a98e56e..4d9fbe60ce17 100644 --- a/bolt/src/Passes/DataflowAnalysis.h +++ b/bolt/include/bolt/Passes/DataflowAnalysis.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_DATAFLOWANALYSIS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_DATAFLOWANALYSIS_H -#include "BinaryContext.h" -#include "BinaryFunction.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/Errc.h" #include diff --git a/bolt/src/Passes/DataflowInfoManager.h b/bolt/include/bolt/Passes/DataflowInfoManager.h similarity index 91% rename from bolt/src/Passes/DataflowInfoManager.h rename to bolt/include/bolt/Passes/DataflowInfoManager.h index 87a03ab03112..26a200fd6937 100644 --- a/bolt/src/Passes/DataflowInfoManager.h +++ b/bolt/include/bolt/Passes/DataflowInfoManager.h @@ -11,13 +11,13 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_DATAFLOWINFOMANAGER_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_DATAFLOWINFOMANAGER_H -#include "DominatorAnalysis.h" -#include "LivenessAnalysis.h" -#include "ReachingDefOrUse.h" -#include "ReachingInsns.h" -#include "StackAllocationAnalysis.h" -#include "StackPointerTracking.h" -#include "StackReachingUses.h" +#include "bolt/Passes/DominatorAnalysis.h" +#include "bolt/Passes/LivenessAnalysis.h" +#include "bolt/Passes/ReachingDefOrUse.h" +#include "bolt/Passes/ReachingInsns.h" +#include "bolt/Passes/StackAllocationAnalysis.h" +#include "bolt/Passes/StackPointerTracking.h" +#include "bolt/Passes/StackReachingUses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/DominatorAnalysis.h b/bolt/include/bolt/Passes/DominatorAnalysis.h similarity index 99% rename from bolt/src/Passes/DominatorAnalysis.h rename to bolt/include/bolt/Passes/DominatorAnalysis.h index a6d5f32dc8bb..1e2bde6d61b8 100644 --- a/bolt/src/Passes/DominatorAnalysis.h +++ b/bolt/include/bolt/Passes/DominatorAnalysis.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_DOMINATORANALYSIS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_DOMINATORANALYSIS_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Timer.h" diff --git a/bolt/src/Passes/FrameAnalysis.h b/bolt/include/bolt/Passes/FrameAnalysis.h similarity index 99% rename from bolt/src/Passes/FrameAnalysis.h rename to bolt/include/bolt/Passes/FrameAnalysis.h index fca4a2962f84..cf1461183cbe 100644 --- a/bolt/src/Passes/FrameAnalysis.h +++ b/bolt/include/bolt/Passes/FrameAnalysis.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEANALYSIS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEANALYSIS_H -#include "StackPointerTracking.h" +#include "bolt/Passes/StackPointerTracking.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/FrameOptimizer.h b/bolt/include/bolt/Passes/FrameOptimizer.h similarity index 99% rename from bolt/src/Passes/FrameOptimizer.h rename to bolt/include/bolt/Passes/FrameOptimizer.h index 683552c902fb..d327d975ec78 100644 --- a/bolt/src/Passes/FrameOptimizer.h +++ b/bolt/include/bolt/Passes/FrameOptimizer.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEOPTIMIZER_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_FRAMEOPTIMIZER_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/HFSort.h b/bolt/include/bolt/Passes/HFSort.h similarity index 99% rename from bolt/src/Passes/HFSort.h rename to bolt/include/bolt/Passes/HFSort.h index 506f59bf76b7..64634c86f0ec 100644 --- a/bolt/src/Passes/HFSort.h +++ b/bolt/include/bolt/Passes/HFSort.h @@ -36,7 +36,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_HFSORT_H #define LLVM_TOOLS_LLVM_BOLT_HFSORT_H -#include "CallGraph.h" +#include "bolt/Passes/CallGraph.h" #include #include diff --git a/bolt/src/Passes/IdenticalCodeFolding.h b/bolt/include/bolt/Passes/IdenticalCodeFolding.h similarity index 94% rename from bolt/src/Passes/IdenticalCodeFolding.h rename to bolt/include/bolt/Passes/IdenticalCodeFolding.h index 886374f8de6c..e5dae332e604 100644 --- a/bolt/src/Passes/IdenticalCodeFolding.h +++ b/bolt/include/bolt/Passes/IdenticalCodeFolding.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_IDENTICAL_CODE_FOLDING_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_IDENTICAL_CODE_FOLDING_H -#include "BinaryFunction.h" -#include "Passes/BinaryPasses.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/IndirectCallPromotion.h b/bolt/include/bolt/Passes/IndirectCallPromotion.h similarity index 99% rename from bolt/src/Passes/IndirectCallPromotion.h rename to bolt/include/bolt/Passes/IndirectCallPromotion.h index a417202ed24f..0fb39b671469 100644 --- a/bolt/src/Passes/IndirectCallPromotion.h +++ b/bolt/include/bolt/Passes/IndirectCallPromotion.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_INDIRECT_CALL_PROMOTION_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_INDIRECT_CALL_PROMOTION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/Inliner.h b/bolt/include/bolt/Passes/Inliner.h similarity index 98% rename from bolt/src/Passes/Inliner.h rename to bolt/include/bolt/Passes/Inliner.h index 84fd37f89b13..64926743b9a6 100644 --- a/bolt/src/Passes/Inliner.h +++ b/bolt/include/bolt/Passes/Inliner.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_INLINER_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_INLINER_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/Instrumentation.h b/bolt/include/bolt/Passes/Instrumentation.h similarity index 98% rename from bolt/src/Passes/Instrumentation.h rename to bolt/include/bolt/Passes/Instrumentation.h index eedc5999cc4a..298505e8647d 100644 --- a/bolt/src/Passes/Instrumentation.h +++ b/bolt/include/bolt/Passes/Instrumentation.h @@ -16,8 +16,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_INSTRUMENTATION_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_INSTRUMENTATION_H -#include "BinaryPasses.h" -#include "Passes/InstrumentationSummary.h" +#include "bolt/Passes/BinaryPasses.h" +#include "bolt/Passes/InstrumentationSummary.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/InstrumentationSummary.h b/bolt/include/bolt/Passes/InstrumentationSummary.h similarity index 100% rename from bolt/src/Passes/InstrumentationSummary.h rename to bolt/include/bolt/Passes/InstrumentationSummary.h diff --git a/bolt/src/Passes/JTFootprintReduction.h b/bolt/include/bolt/Passes/JTFootprintReduction.h similarity index 98% rename from bolt/src/Passes/JTFootprintReduction.h rename to bolt/include/bolt/Passes/JTFootprintReduction.h index ac44dfd8477a..c086c1d11fdc 100644 --- a/bolt/src/Passes/JTFootprintReduction.h +++ b/bolt/include/bolt/Passes/JTFootprintReduction.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_JT_FOOTPRINT_REDUCTION_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_JT_FOOTPRINT_REDUCTION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/LivenessAnalysis.h b/bolt/include/bolt/Passes/LivenessAnalysis.h similarity index 98% rename from bolt/src/Passes/LivenessAnalysis.h rename to bolt/include/bolt/Passes/LivenessAnalysis.h index bb5d2607d7f5..b66e823cb0e0 100644 --- a/bolt/src/Passes/LivenessAnalysis.h +++ b/bolt/include/bolt/Passes/LivenessAnalysis.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_LIVENESSANALYSIS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_LIVENESSANALYSIS_H -#include "DataflowAnalysis.h" -#include "RegAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" +#include "bolt/Passes/RegAnalysis.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/LongJmp.h b/bolt/include/bolt/Passes/LongJmp.h similarity index 99% rename from bolt/src/Passes/LongJmp.h rename to bolt/include/bolt/Passes/LongJmp.h index 5c292b7882f2..acbb7187215f 100644 --- a/bolt/src/Passes/LongJmp.h +++ b/bolt/include/bolt/Passes/LongJmp.h @@ -10,7 +10,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_LONGJMP_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_LONGJMP_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/LoopInversionPass.h b/bolt/include/bolt/Passes/LoopInversionPass.h similarity index 97% rename from bolt/src/Passes/LoopInversionPass.h rename to bolt/include/bolt/Passes/LoopInversionPass.h index 2ade6a87eb0f..462c8dcde1a5 100644 --- a/bolt/src/Passes/LoopInversionPass.h +++ b/bolt/include/bolt/Passes/LoopInversionPass.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_LOOPINVERSION_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_LOOPINVERSION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" // This pass founds cases when BBs have layout: // #BB0: diff --git a/bolt/src/Passes/MCF.h b/bolt/include/bolt/Passes/MCF.h similarity index 100% rename from bolt/src/Passes/MCF.h rename to bolt/include/bolt/Passes/MCF.h diff --git a/bolt/src/Passes/PLTCall.h b/bolt/include/bolt/Passes/PLTCall.h similarity index 96% rename from bolt/src/Passes/PLTCall.h rename to bolt/include/bolt/Passes/PLTCall.h index 065e0f56028e..2b238d3cdbee 100644 --- a/bolt/src/Passes/PLTCall.h +++ b/bolt/include/bolt/Passes/PLTCall.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_PLTCALL_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_PLTCALL_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/PatchEntries.h b/bolt/include/bolt/Passes/PatchEntries.h similarity index 90% rename from bolt/src/Passes/PatchEntries.h rename to bolt/include/bolt/Passes/PatchEntries.h index 56ef71feef31..9e7ff00f1519 100644 --- a/bolt/src/Passes/PatchEntries.h +++ b/bolt/include/bolt/Passes/PatchEntries.h @@ -1,4 +1,4 @@ -//===--- Passes/PatchEntries.h - pass for patching function entries -------===// +//===--- PatchEntries.h - pass for patching function entries --------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_PATCH_ENTRIES_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_PATCH_ENTRIES_H -#include "Passes/BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/ReachingDefOrUse.h b/bolt/include/bolt/Passes/ReachingDefOrUse.h similarity index 98% rename from bolt/src/Passes/ReachingDefOrUse.h rename to bolt/include/bolt/Passes/ReachingDefOrUse.h index 12048982d9dc..757bdd764fc6 100644 --- a/bolt/src/Passes/ReachingDefOrUse.h +++ b/bolt/include/bolt/Passes/ReachingDefOrUse.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REACHINGDEFORUSE_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REACHINGDEFORUSE_H -#include "DataflowAnalysis.h" -#include "RegAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" +#include "bolt/Passes/RegAnalysis.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Timer.h" diff --git a/bolt/src/Passes/ReachingInsns.h b/bolt/include/bolt/Passes/ReachingInsns.h similarity index 98% rename from bolt/src/Passes/ReachingInsns.h rename to bolt/include/bolt/Passes/ReachingInsns.h index b98022c406fa..5f86e0453a44 100644 --- a/bolt/src/Passes/ReachingInsns.h +++ b/bolt/include/bolt/Passes/ReachingInsns.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REACHINGINSNS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REACHINGINSNS_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Timer.h" diff --git a/bolt/src/Passes/RegAnalysis.h b/bolt/include/bolt/Passes/RegAnalysis.h similarity index 100% rename from bolt/src/Passes/RegAnalysis.h rename to bolt/include/bolt/Passes/RegAnalysis.h diff --git a/bolt/src/Passes/RegReAssign.h b/bolt/include/bolt/Passes/RegReAssign.h similarity index 96% rename from bolt/src/Passes/RegReAssign.h rename to bolt/include/bolt/Passes/RegReAssign.h index 28c0795f3b30..7c675834cf74 100644 --- a/bolt/src/Passes/RegReAssign.h +++ b/bolt/include/bolt/Passes/RegReAssign.h @@ -10,8 +10,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REGREASSIGN_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REGREASSIGN_H -#include "BinaryPasses.h" -#include "RegAnalysis.h" +#include "bolt/Passes/BinaryPasses.h" +#include "bolt/Passes/RegAnalysis.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/ReorderAlgorithm.h b/bolt/include/bolt/Passes/ReorderAlgorithm.h similarity index 99% rename from bolt/src/Passes/ReorderAlgorithm.h rename to bolt/include/bolt/Passes/ReorderAlgorithm.h index abcccd39c084..5212e625d3cb 100644 --- a/bolt/src/Passes/ReorderAlgorithm.h +++ b/bolt/include/bolt/Passes/ReorderAlgorithm.h @@ -13,9 +13,9 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_ALGORITHM_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_ALGORITHM_H -#include "BinaryFunction.h" -#include +#include "bolt/Core/BinaryFunction.h" #include +#include #include diff --git a/bolt/src/Passes/ReorderData.h b/bolt/include/bolt/Passes/ReorderData.h similarity index 98% rename from bolt/src/Passes/ReorderData.h rename to bolt/include/bolt/Passes/ReorderData.h index e84b55a7ca85..67ca440dbe46 100644 --- a/bolt/src/Passes/ReorderData.h +++ b/bolt/include/bolt/Passes/ReorderData.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_DATA_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_DATA_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" #include namespace llvm { diff --git a/bolt/src/Passes/ReorderFunctions.h b/bolt/include/bolt/Passes/ReorderFunctions.h similarity index 93% rename from bolt/src/Passes/ReorderFunctions.h rename to bolt/include/bolt/Passes/ReorderFunctions.h index 7ee12c4f7612..028f3c3dc87b 100644 --- a/bolt/src/Passes/ReorderFunctions.h +++ b/bolt/include/bolt/Passes/ReorderFunctions.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_FNCTIONS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_REORDER_FNCTIONS_H -#include "BinaryPasses.h" -#include "BinaryFunctionCallGraph.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/ReorderUtils.h b/bolt/include/bolt/Passes/ReorderUtils.h similarity index 100% rename from bolt/src/Passes/ReorderUtils.h rename to bolt/include/bolt/Passes/ReorderUtils.h diff --git a/bolt/src/Passes/RetpolineInsertion.h b/bolt/include/bolt/Passes/RetpolineInsertion.h similarity index 98% rename from bolt/src/Passes/RetpolineInsertion.h rename to bolt/include/bolt/Passes/RetpolineInsertion.h index 07982837c4d1..75dcb4d67c91 100644 --- a/bolt/src/Passes/RetpolineInsertion.h +++ b/bolt/include/bolt/Passes/RetpolineInsertion.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_RETPOLINE_INSERTION_H #define LLVM_TOOLS_LLVM_BOLT_RETPOLINE_INSERTION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" #include #include diff --git a/bolt/src/Passes/ShrinkWrapping.h b/bolt/include/bolt/Passes/ShrinkWrapping.h similarity index 99% rename from bolt/src/Passes/ShrinkWrapping.h rename to bolt/include/bolt/Passes/ShrinkWrapping.h index 5e33910b4b3c..cc53f829aa61 100644 --- a/bolt/src/Passes/ShrinkWrapping.h +++ b/bolt/include/bolt/Passes/ShrinkWrapping.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_SHRINKWRAPPING_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_SHRINKWRAPPING_H -#include "FrameAnalysis.h" +#include "bolt/Passes/FrameAnalysis.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/SplitFunctions.h b/bolt/include/bolt/Passes/SplitFunctions.h similarity index 97% rename from bolt/src/Passes/SplitFunctions.h rename to bolt/include/bolt/Passes/SplitFunctions.h index 8714aa3598ae..583991029c63 100644 --- a/bolt/src/Passes/SplitFunctions.h +++ b/bolt/include/bolt/Passes/SplitFunctions.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_SPLIT_FUNCTIONS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_SPLIT_FUNCTIONS_H -#include "Passes/BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/StackAllocationAnalysis.h b/bolt/include/bolt/Passes/StackAllocationAnalysis.h similarity index 98% rename from bolt/src/Passes/StackAllocationAnalysis.h rename to bolt/include/bolt/Passes/StackAllocationAnalysis.h index 6bce6a67d410..155fa5163761 100644 --- a/bolt/src/Passes/StackAllocationAnalysis.h +++ b/bolt/include/bolt/Passes/StackAllocationAnalysis.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_STACKALLOCATIONANALYSIS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_STACKALLOCATIONANALYSIS_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/StackAvailableExpressions.h b/bolt/include/bolt/Passes/StackAvailableExpressions.h similarity index 97% rename from bolt/src/Passes/StackAvailableExpressions.h rename to bolt/include/bolt/Passes/StackAvailableExpressions.h index b6aaedbf2057..889832d7ae67 100644 --- a/bolt/src/Passes/StackAvailableExpressions.h +++ b/bolt/include/bolt/Passes/StackAvailableExpressions.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_STACKAVAILABLEEXPRESSIONS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_STACKAVAILABLEEXPRESSIONS_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/StackPointerTracking.h b/bolt/include/bolt/Passes/StackPointerTracking.h similarity index 99% rename from bolt/src/Passes/StackPointerTracking.h rename to bolt/include/bolt/Passes/StackPointerTracking.h index d31cc7cd5b0b..0d64e06cd439 100644 --- a/bolt/src/Passes/StackPointerTracking.h +++ b/bolt/include/bolt/Passes/StackPointerTracking.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_STACKPOINTERTRACKING_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_STACKPOINTERTRACKING_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/StackReachingUses.h b/bolt/include/bolt/Passes/StackReachingUses.h similarity index 98% rename from bolt/src/Passes/StackReachingUses.h rename to bolt/include/bolt/Passes/StackReachingUses.h index 5bb30233b8eb..2d5c1a1f12b1 100644 --- a/bolt/src/Passes/StackReachingUses.h +++ b/bolt/include/bolt/Passes/StackReachingUses.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_STACKREACHINGUSES_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_STACKREACHINGUSES_H -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/StokeInfo.h b/bolt/include/bolt/Passes/StokeInfo.h similarity index 99% rename from bolt/src/Passes/StokeInfo.h rename to bolt/include/bolt/Passes/StokeInfo.h index 1fc6e5e57857..55fef4e7fcc3 100644 --- a/bolt/src/Passes/StokeInfo.h +++ b/bolt/include/bolt/Passes/StokeInfo.h @@ -25,8 +25,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_STOKEINFO_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_STOKEINFO_H +#include "bolt/Passes/BinaryPasses.h" #include -#include "BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/TailDuplication.h b/bolt/include/bolt/Passes/TailDuplication.h similarity index 99% rename from bolt/src/Passes/TailDuplication.h rename to bolt/include/bolt/Passes/TailDuplication.h index a4a00fc32728..333e7cc7eccd 100644 --- a/bolt/src/Passes/TailDuplication.h +++ b/bolt/include/bolt/Passes/TailDuplication.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_TAILDUPLICATION_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_TAILDUPLICATION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" // This pass founds cases when BBs have layout: // #BB0: diff --git a/bolt/src/Passes/ThreeWayBranch.h b/bolt/include/bolt/Passes/ThreeWayBranch.h similarity index 97% rename from bolt/src/Passes/ThreeWayBranch.h rename to bolt/include/bolt/Passes/ThreeWayBranch.h index 3732735f1d35..8128a42b1f79 100644 --- a/bolt/src/Passes/ThreeWayBranch.h +++ b/bolt/include/bolt/Passes/ThreeWayBranch.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_THREEWAYBRANCH_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_THREEWAYBRANCH_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/ValidateInternalCalls.h b/bolt/include/bolt/Passes/ValidateInternalCalls.h similarity index 99% rename from bolt/src/Passes/ValidateInternalCalls.h rename to bolt/include/bolt/Passes/ValidateInternalCalls.h index c0bb01ed165c..e728e9e8d3f6 100644 --- a/bolt/src/Passes/ValidateInternalCalls.h +++ b/bolt/include/bolt/Passes/ValidateInternalCalls.h @@ -10,7 +10,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PASSES_VALIDATEINTERNALCALLS_H #define LLVM_TOOLS_LLVM_BOLT_PASSES_VALIDATEINTERNALCALLS_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/VeneerElimination.h b/bolt/include/bolt/Passes/VeneerElimination.h similarity index 96% rename from bolt/src/Passes/VeneerElimination.h rename to bolt/include/bolt/Passes/VeneerElimination.h index 7897623d5911..008cd7811d2b 100644 --- a/bolt/src/Passes/VeneerElimination.h +++ b/bolt/include/bolt/Passes/VeneerElimination.h @@ -11,7 +11,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_VENEER_ELIMINATION_H #define LLVM_TOOLS_LLVM_BOLT_VENEER_ELIMINATION_H -#include "BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" namespace llvm { namespace bolt { diff --git a/bolt/src/BoltAddressTranslation.h b/bolt/include/bolt/Profile/BoltAddressTranslation.h similarity index 100% rename from bolt/src/BoltAddressTranslation.h rename to bolt/include/bolt/Profile/BoltAddressTranslation.h diff --git a/bolt/src/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h similarity index 99% rename from bolt/src/DataAggregator.h rename to bolt/include/bolt/Profile/DataAggregator.h index 0d153e7af454..a429d2ed1c9a 100644 --- a/bolt/src/DataAggregator.h +++ b/bolt/include/bolt/Profile/DataAggregator.h @@ -14,7 +14,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_DATA_AGGREGATOR_H #define LLVM_TOOLS_LLVM_BOLT_DATA_AGGREGATOR_H -#include "DataReader.h" +#include "bolt/Profile/DataReader.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/Program.h" diff --git a/bolt/src/DataReader.h b/bolt/include/bolt/Profile/DataReader.h similarity index 99% rename from bolt/src/DataReader.h rename to bolt/include/bolt/Profile/DataReader.h index 294dec7f2cb3..4e64924f2943 100644 --- a/bolt/src/DataReader.h +++ b/bolt/include/bolt/Profile/DataReader.h @@ -14,7 +14,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_DATA_READER_H #define LLVM_TOOLS_LLVM_BOLT_DATA_READER_H -#include "ProfileReaderBase.h" +#include "bolt/Profile/ProfileReaderBase.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" diff --git a/bolt/src/Heatmap.h b/bolt/include/bolt/Profile/Heatmap.h similarity index 100% rename from bolt/src/Heatmap.h rename to bolt/include/bolt/Profile/Heatmap.h diff --git a/bolt/src/ProfileReaderBase.h b/bolt/include/bolt/Profile/ProfileReaderBase.h similarity index 100% rename from bolt/src/ProfileReaderBase.h rename to bolt/include/bolt/Profile/ProfileReaderBase.h diff --git a/bolt/src/ProfileYAMLMapping.h b/bolt/include/bolt/Profile/ProfileYAMLMapping.h similarity index 99% rename from bolt/src/ProfileYAMLMapping.h rename to bolt/include/bolt/Profile/ProfileYAMLMapping.h index 948f5700e459..465eb62de60f 100644 --- a/bolt/src/ProfileYAMLMapping.h +++ b/bolt/include/bolt/Profile/ProfileYAMLMapping.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_PROFILEYAMLMAPPING_H #define LLVM_TOOLS_LLVM_BOLT_PROFILEYAMLMAPPING_H -#include "BinaryFunction.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/YAMLTraits.h" #include diff --git a/bolt/src/YAMLProfileReader.h b/bolt/include/bolt/Profile/YAMLProfileReader.h similarity index 97% rename from bolt/src/YAMLProfileReader.h rename to bolt/include/bolt/Profile/YAMLProfileReader.h index 5561e80b8828..4e99dc42f584 100644 --- a/bolt/src/YAMLProfileReader.h +++ b/bolt/include/bolt/Profile/YAMLProfileReader.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_YAML_PROFILE_READER_H #define LLVM_TOOLS_LLVM_BOLT_YAML_PROFILE_READER_H -#include "ProfileReaderBase.h" -#include "ProfileYAMLMapping.h" +#include "bolt/Profile/ProfileReaderBase.h" +#include "bolt/Profile/ProfileYAMLMapping.h" #include namespace llvm { diff --git a/bolt/src/YAMLProfileWriter.h b/bolt/include/bolt/Profile/YAMLProfileWriter.h similarity index 100% rename from bolt/src/YAMLProfileWriter.h rename to bolt/include/bolt/Profile/YAMLProfileWriter.h diff --git a/bolt/src/BinaryPassManager.h b/bolt/include/bolt/Rewrite/BinaryPassManager.h similarity index 97% rename from bolt/src/BinaryPassManager.h rename to bolt/include/bolt/Rewrite/BinaryPassManager.h index 511ddaad637a..7827cf875b23 100644 --- a/bolt/src/BinaryPassManager.h +++ b/bolt/include/bolt/Rewrite/BinaryPassManager.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_PASS_MANAGER_H #define LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_PASS_MANAGER_H -#include "Passes/BinaryPasses.h" +#include "bolt/Passes/BinaryPasses.h" #include #include diff --git a/bolt/src/DWARFRewriter.h b/bolt/include/bolt/Rewrite/DWARFRewriter.h similarity index 99% rename from bolt/src/DWARFRewriter.h rename to bolt/include/bolt/Rewrite/DWARFRewriter.h index 2b4310ccc71d..7b420915e6f7 100644 --- a/bolt/src/DWARFRewriter.h +++ b/bolt/include/bolt/Rewrite/DWARFRewriter.h @@ -11,8 +11,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_DWARF_REWRITER_H #define LLVM_TOOLS_LLVM_BOLT_DWARF_REWRITER_H -#include "DebugData.h" -#include "RewriteInstance.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Rewrite/RewriteInstance.h" #include #include #include diff --git a/bolt/src/ExecutableFileMemoryManager.h b/bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h similarity index 100% rename from bolt/src/ExecutableFileMemoryManager.h rename to bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h diff --git a/bolt/src/MachORewriteInstance.h b/bolt/include/bolt/Rewrite/MachORewriteInstance.h similarity index 98% rename from bolt/src/MachORewriteInstance.h rename to bolt/include/bolt/Rewrite/MachORewriteInstance.h index 5f9551723b2e..cf6b8b1247ed 100644 --- a/bolt/src/MachORewriteInstance.h +++ b/bolt/include/bolt/Rewrite/MachORewriteInstance.h @@ -13,7 +13,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_MACHO_REWRITE_INSTANCE_H #define LLVM_TOOLS_LLVM_BOLT_MACHO_REWRITE_INSTANCE_H -#include "NameResolver.h" +#include "bolt/Utils/NameResolver.h" #include "llvm/Support/Error.h" #include diff --git a/bolt/src/RewriteInstance.h b/bolt/include/bolt/Rewrite/RewriteInstance.h similarity index 99% rename from bolt/src/RewriteInstance.h rename to bolt/include/bolt/Rewrite/RewriteInstance.h index c17f23e1cec8..533aa2996494 100644 --- a/bolt/src/RewriteInstance.h +++ b/bolt/include/bolt/Rewrite/RewriteInstance.h @@ -13,8 +13,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_REWRITE_INSTANCE_H #define LLVM_TOOLS_LLVM_BOLT_REWRITE_INSTANCE_H -#include "BinaryContext.h" -#include "NameResolver.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Utils/NameResolver.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/MC/StringTableBuilder.h" #include "llvm/Object/ELFObjectFile.h" diff --git a/bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h b/bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h similarity index 96% rename from bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h rename to bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h index c24374ed925a..2c7c2f919e41 100644 --- a/bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h +++ b/bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h @@ -9,7 +9,7 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_HUGIFY_RUNTIME_LIBRARY_H #define LLVM_TOOLS_LLVM_BOLT_HUGIFY_RUNTIME_LIBRARY_H -#include "RuntimeLibs/RuntimeLibrary.h" +#include "bolt/RuntimeLibs/RuntimeLibrary.h" namespace llvm { namespace bolt { diff --git a/bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h b/bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h similarity index 94% rename from bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h rename to bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h index 39f1691d5d2c..4bee69c1bac2 100644 --- a/bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h +++ b/bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h @@ -9,8 +9,8 @@ #ifndef LLVM_TOOLS_LLVM_BOLT_INSTRUMENTATION_RUNTIME_LIBRARY_H #define LLVM_TOOLS_LLVM_BOLT_INSTRUMENTATION_RUNTIME_LIBRARY_H -#include "Passes/InstrumentationSummary.h" -#include "RuntimeLibs/RuntimeLibrary.h" +#include "bolt/Passes/InstrumentationSummary.h" +#include "bolt/RuntimeLibs/RuntimeLibrary.h" namespace llvm { namespace bolt { diff --git a/bolt/src/RuntimeLibs/RuntimeLibrary.h b/bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h similarity index 100% rename from bolt/src/RuntimeLibs/RuntimeLibrary.h rename to bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h diff --git a/bolt/include/bolt/Utils/CommandLineOpts.h b/bolt/include/bolt/Utils/CommandLineOpts.h new file mode 100644 index 000000000000..33429e26bc02 --- /dev/null +++ b/bolt/include/bolt/Utils/CommandLineOpts.h @@ -0,0 +1,82 @@ +//===--- CommandLineOpts.h - BOLT CLI options -----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// BOLT CLI options +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_TOOLS_LLVM_BOLT_COMMAND_LINE_OPTS_H +#define LLVM_TOOLS_LLVM_BOLT_COMMAND_LINE_OPTS_H + +#include "llvm/Support/CommandLine.h" + +namespace opts { + +extern bool HeatmapMode; +extern bool LinuxKernelMode; + +extern llvm::cl::OptionCategory BoltCategory; +extern llvm::cl::OptionCategory BoltDiffCategory; +extern llvm::cl::OptionCategory BoltOptCategory; +extern llvm::cl::OptionCategory BoltRelocCategory; +extern llvm::cl::OptionCategory BoltOutputCategory; +extern llvm::cl::OptionCategory AggregatorCategory; +extern llvm::cl::OptionCategory BoltInstrCategory; + +extern llvm::cl::SubCommand HeatmapCommand; + +extern llvm::cl::opt AlignText; +extern llvm::cl::opt AggregateOnly; +extern llvm::cl::opt BucketsPerLine; +extern llvm::cl::opt DiffOnly; +extern llvm::cl::opt EnableBAT; +extern llvm::cl::opt RemoveSymtab; +extern llvm::cl::opt ExecutionCountThreshold; +extern llvm::cl::opt HeatmapBlock; +extern llvm::cl::opt HeatmapFile; +extern llvm::cl::opt HeatmapMaxAddress; +extern llvm::cl::opt HeatmapMinAddress; +extern llvm::cl::opt HotData; +extern llvm::cl::opt HotFunctionsAtEnd; +extern llvm::cl::opt HotText; +extern llvm::cl::opt InputFilename; +extern llvm::cl::opt Instrument; +extern llvm::cl::opt OutputFilename; +extern llvm::cl::opt PerfData; +extern llvm::cl::opt PrintCacheMetrics; +extern llvm::cl::opt PrintSections; +extern llvm::cl::opt SplitEH; +extern llvm::cl::opt StrictMode; +extern llvm::cl::opt TimeOpts; +extern llvm::cl::opt UseOldText; +extern llvm::cl::opt UpdateDebugSections; + +// The default verbosity level (0) is pretty terse, level 1 is fairly +// verbose and usually prints some informational message for every +// function processed. Level 2 is for the noisiest of messages and +// often prints a message per basic block. +// Error messages should never be suppressed by the verbosity level. +// Only warnings and info messages should be affected. +// +// The rationale behind stream usage is as follows: +// outs() for info and debugging controlled by command line flags. +// errs() for errors and warnings. +// dbgs() for output within DEBUG(). +extern llvm::cl::opt Verbosity; + +/// Return true if we should process all functions in the binary. +bool processAllFunctions(); + +} + +namespace llvm { +namespace bolt { +extern const char *BoltRevision; +} +} + +#endif diff --git a/bolt/src/NameResolver.h b/bolt/include/bolt/Utils/NameResolver.h similarity index 100% rename from bolt/src/NameResolver.h rename to bolt/include/bolt/Utils/NameResolver.h diff --git a/bolt/src/NameShortener.h b/bolt/include/bolt/Utils/NameShortener.h similarity index 100% rename from bolt/src/NameShortener.h rename to bolt/include/bolt/Utils/NameShortener.h diff --git a/bolt/src/Utils.h b/bolt/include/bolt/Utils/Utils.h similarity index 100% rename from bolt/src/Utils.h rename to bolt/include/bolt/Utils/Utils.h diff --git a/bolt/lib/CMakeLists.txt b/bolt/lib/CMakeLists.txt new file mode 100644 index 000000000000..22a6be44f645 --- /dev/null +++ b/bolt/lib/CMakeLists.txt @@ -0,0 +1,7 @@ +add_subdirectory(Core) +add_subdirectory(Passes) +add_subdirectory(Profile) +add_subdirectory(Rewrite) +add_subdirectory(RuntimeLibs) +add_subdirectory(Target) +add_subdirectory(Utils) diff --git a/bolt/src/BinaryBasicBlock.cpp b/bolt/lib/Core/BinaryBasicBlock.cpp similarity index 99% rename from bolt/src/BinaryBasicBlock.cpp rename to bolt/lib/Core/BinaryBasicBlock.cpp index 9213c8261511..8693634c37c6 100644 --- a/bolt/src/BinaryBasicBlock.cpp +++ b/bolt/lib/Core/BinaryBasicBlock.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "BinaryBasicBlock.h" -#include "BinaryContext.h" -#include "BinaryFunction.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/Errc.h" diff --git a/bolt/src/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp similarity index 97% rename from bolt/src/BinaryContext.cpp rename to bolt/lib/Core/BinaryContext.cpp index 9af75697e1d9..63a2f384b88c 100644 --- a/bolt/src/BinaryContext.cpp +++ b/bolt/lib/Core/BinaryContext.cpp @@ -8,11 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "BinaryContext.h" -#include "BinaryEmitter.h" -#include "BinaryFunction.h" -#include "NameResolver.h" -#include "Utils.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryEmitter.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Utils/CommandLineOpts.h" +#include "bolt/Utils/NameResolver.h" +#include "bolt/Utils/Utils.h" #include "llvm/ADT/Twine.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" @@ -38,18 +39,6 @@ using namespace llvm; namespace opts { -extern cl::OptionCategory BoltCategory; - -extern cl::opt AggregateOnly; -extern cl::opt HotText; -extern cl::opt HotData; -extern cl::opt StrictMode; -extern cl::opt UseOldText; -extern cl::opt Verbosity; -extern cl::opt ExecutionCountThreshold; - -extern bool processAllFunctions(); - cl::opt NoHugePages("no-huge-pages", cl::desc("use regular size pages for code alignment"), @@ -130,34 +119,6 @@ BinaryContext::~BinaryContext() { clearBinaryData(); } -extern MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *, - const MCInstrInfo *, - const MCRegisterInfo *); -extern MCPlusBuilder *createAArch64MCPlusBuilder(const MCInstrAnalysis *, - const MCInstrInfo *, - const MCRegisterInfo *); - -namespace { - -MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch, - const MCInstrAnalysis *Analysis, - const MCInstrInfo *Info, - const MCRegisterInfo *RegInfo) { -#ifdef X86_AVAILABLE - if (Arch == Triple::x86_64) - return createX86MCPlusBuilder(Analysis, Info, RegInfo); -#endif - -#ifdef AARCH64_AVAILABLE - if (Arch == Triple::aarch64) - return createAArch64MCPlusBuilder(Analysis, Info, RegInfo); -#endif - - llvm_unreachable("architecture unsupport by MCPlusBuilder"); -} - -} // anonymous namespace - /// Create BinaryContext for a given architecture \p ArchName and /// triple \p TripleName. std::unique_ptr @@ -256,14 +217,6 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC, return nullptr; } - std::unique_ptr MIB(createMCPlusBuilder( - TheTriple->getArch(), MIA.get(), MII.get(), MRI.get())); - if (!MIB) { - errs() << "BOLT-ERROR: failed to create instruction builder for target" - << TripleName << "\n"; - return nullptr; - } - int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); std::unique_ptr InstructionPrinter( TheTarget->createMCInstPrinter(*TheTriple, AsmPrinterVariant, *AsmInfo, @@ -287,7 +240,7 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC, std::move(Ctx), std::move(DwCtx), std::move(TheTriple), TheTarget, std::string(TripleName), std::move(MCE), std::move(MOFI), std::move(AsmInfo), std::move(MII), std::move(STI), - std::move(InstructionPrinter), std::move(MIA), std::move(MIB), + std::move(InstructionPrinter), std::move(MIA), nullptr, std::move(MRI), std::move(DisAsm)); BC->TTypeEncoding = TTypeEncoding; diff --git a/bolt/src/BinaryData.cpp b/bolt/lib/Core/BinaryData.cpp similarity index 98% rename from bolt/src/BinaryData.cpp rename to bolt/lib/Core/BinaryData.cpp index 8a2fbe41ef80..99306ae10aa9 100644 --- a/bolt/src/BinaryData.cpp +++ b/bolt/lib/Core/BinaryData.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "BinaryData.h" -#include "BinarySection.h" +#include "bolt/Core/BinaryData.h" +#include "bolt/Core/BinarySection.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Regex.h" diff --git a/bolt/src/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp similarity index 98% rename from bolt/src/BinaryEmitter.cpp rename to bolt/lib/Core/BinaryEmitter.cpp index 2df9e6004f86..bf6a0b245d93 100644 --- a/bolt/src/BinaryEmitter.cpp +++ b/bolt/lib/Core/BinaryEmitter.cpp @@ -8,11 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "BinaryEmitter.h" -#include "BinaryContext.h" -#include "BinaryFunction.h" -#include "DebugData.h" -#include "Utils.h" +#include "bolt/Core/BinaryEmitter.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Utils/CommandLineOpts.h" +#include "bolt/Utils/Utils.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/CommandLine.h" @@ -27,17 +28,8 @@ using namespace bolt; namespace opts { -extern cl::OptionCategory BoltCategory; -extern cl::OptionCategory BoltOptCategory; -extern cl::OptionCategory BoltRelocCategory; - -extern cl::opt AlignText; -extern cl::opt HotText; extern cl::opt JumpTables; extern cl::opt PreserveBlocksAlignment; -extern cl::opt PrintCacheMetrics; -extern cl::opt UpdateDebugSections; -extern cl::opt Verbosity; cl::opt AlignBlocks("align-blocks", diff --git a/bolt/src/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp similarity index 99% rename from bolt/src/BinaryFunction.cpp rename to bolt/lib/Core/BinaryFunction.cpp index 9414b83ad070..384717a42753 100644 --- a/bolt/src/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -8,13 +8,13 @@ // //===----------------------------------------------------------------------===// -#include "BinaryFunction.h" -#include "BinaryBasicBlock.h" -#include "DynoStats.h" -#include "MCPlusBuilder.h" -#include "NameResolver.h" -#include "NameShortener.h" -#include "Utils.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/DynoStats.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Utils/NameResolver.h" +#include "bolt/Utils/NameShortener.h" +#include "bolt/Utils/Utils.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/edit_distance.h" diff --git a/bolt/src/BinaryFunctionProfile.cpp b/bolt/lib/Core/BinaryFunctionProfile.cpp similarity index 90% rename from bolt/src/BinaryFunctionProfile.cpp rename to bolt/lib/Core/BinaryFunctionProfile.cpp index 6b72a1a44c71..3d34f5e93650 100644 --- a/bolt/src/BinaryFunctionProfile.cpp +++ b/bolt/lib/Core/BinaryFunctionProfile.cpp @@ -8,10 +8,8 @@ // //===----------------------------------------------------------------------===// - -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" -#include "Passes/MCF.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -26,29 +24,20 @@ namespace opts { extern cl::OptionCategory BoltOptCategory; -extern cl::opt IndirectCallPromotion; -extern cl::opt JumpTables; - -static cl::opt -DoMCF("mcf", - cl::desc("solve a min cost flow problem on the CFG to fix edge counts " - "(default=disable)"), - cl::init(MCF_DISABLE), +cl::opt +IndirectCallPromotion("indirect-call-promotion", + cl::init(ICP_NONE), + cl::desc("indirect call promotion"), cl::values( - clEnumValN(MCF_DISABLE, "none", - "disable MCF"), - clEnumValN(MCF_LINEAR, "linear", - "cost function is inversely proportional to edge count"), - clEnumValN(MCF_QUADRATIC, "quadratic", - "cost function is inversely proportional to edge count squared"), - clEnumValN(MCF_LOG, "log", - "cost function is inversely proportional to log of edge count"), - clEnumValN(MCF_BLAMEFTS, "blamefts", - "tune cost to blame fall-through edges for surplus flow")), + clEnumValN(ICP_NONE, "none", "do not perform indirect call promotion"), + clEnumValN(ICP_CALLS, "calls", "perform ICP on indirect calls"), + clEnumValN(ICP_JUMP_TABLES, "jump-tables", "perform ICP on jump tables"), + clEnumValN(ICP_ALL, "all", "perform ICP on calls and jump tables")), cl::ZeroOrMore, - cl::Hidden, cl::cat(BoltOptCategory)); +extern cl::opt JumpTables; + static cl::opt FixFuncCounts("fix-func-counts", cl::desc("adjust function counts based on basic blocks execution count"), @@ -84,14 +73,8 @@ void BinaryFunction::postProcessProfile() { return; } - if (!(getProfileFlags() & PF_LBR)) { - // Check if MCF post-processing was requested. - if (opts::DoMCF != MCF_DISABLE) { - removeTagsFromProfile(); - solveMCF(*this, opts::DoMCF); - } + if (!(getProfileFlags() & PF_LBR)) return; - } // If we have at least some branch data for the function indicate that it // was executed. @@ -148,12 +131,6 @@ void BinaryFunction::postProcessProfile() { if (opts::InferFallThroughs) inferFallThroughCounts(); - // Check if MCF post-processing was requested. - if (opts::DoMCF != MCF_DISABLE) { - removeTagsFromProfile(); - solveMCF(*this, opts::DoMCF); - } - // Update profile information for jump tables based on CFG branch data. for (BinaryBasicBlock *BB : BasicBlocks) { const MCInst *LastInstr = BB->getLastNonPseudoInstr(); diff --git a/bolt/src/BinarySection.cpp b/bolt/lib/Core/BinarySection.cpp similarity index 99% rename from bolt/src/BinarySection.cpp rename to bolt/lib/Core/BinarySection.cpp index 4b7d632d6962..6c7da86c4c3a 100644 --- a/bolt/src/BinarySection.cpp +++ b/bolt/lib/Core/BinarySection.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "BinarySection.h" -#include "BinaryContext.h" -#include "Utils.h" +#include "bolt/Core/BinarySection.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Utils/Utils.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/CommandLine.h" diff --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt new file mode 100644 index 000000000000..4f7c058e5c60 --- /dev/null +++ b/bolt/lib/Core/CMakeLists.txt @@ -0,0 +1,27 @@ +set(LLVM_LINK_COMPONENTS + BOLTUtils + DebugInfoDWARF + MC + Object + Support + ) + +add_llvm_library(LLVMBOLTCore + BinaryBasicBlock.cpp + BinaryContext.cpp + BinaryData.cpp + BinaryEmitter.cpp + BinaryFunction.cpp + BinaryFunctionProfile.cpp + BinarySection.cpp + DebugData.cpp + DynoStats.cpp + Exceptions.cpp + JumpTable.cpp + MCPlusBuilder.cpp + ParallelUtilities.cpp + Relocation.cpp + + LINK_LIBS + ${LLVM_PTHREAD_LIB} + ) diff --git a/bolt/src/DebugData.cpp b/bolt/lib/Core/DebugData.cpp similarity index 99% rename from bolt/src/DebugData.cpp rename to bolt/lib/Core/DebugData.cpp index a89e1d0e5c36..d88996aa5492 100644 --- a/bolt/src/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -8,11 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "DebugData.h" -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" -#include "Utils.h" - +#include "bolt/Core/DebugData.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Utils/Utils.h" #include "llvm/MC/MCObjectStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/CommandLine.h" diff --git a/bolt/src/DynoStats.cpp b/bolt/lib/Core/DynoStats.cpp similarity index 99% rename from bolt/src/DynoStats.cpp rename to bolt/lib/Core/DynoStats.cpp index f9c25d98deda..e566cefd7262 100644 --- a/bolt/src/DynoStats.cpp +++ b/bolt/lib/Core/DynoStats.cpp @@ -8,10 +8,9 @@ // //===----------------------------------------------------------------------===// - -#include "DynoStats.h" -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" +#include "bolt/Core/DynoStats.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" diff --git a/bolt/src/Exceptions.cpp b/bolt/lib/Core/Exceptions.cpp similarity index 99% rename from bolt/src/Exceptions.cpp rename to bolt/lib/Core/Exceptions.cpp index f73054aa8593..18037b802531 100644 --- a/bolt/src/Exceptions.cpp +++ b/bolt/lib/Core/Exceptions.cpp @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#include "Exceptions.h" -#include "BinaryFunction.h" +#include "bolt/Core/Exceptions.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/Dwarf.h" diff --git a/bolt/src/JumpTable.cpp b/bolt/lib/Core/JumpTable.cpp similarity index 97% rename from bolt/src/JumpTable.cpp rename to bolt/lib/Core/JumpTable.cpp index 700c9bf881a2..67ac3ad097f0 100644 --- a/bolt/src/JumpTable.cpp +++ b/bolt/lib/Core/JumpTable.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "JumpTable.h" -#include "BinaryFunction.h" -#include "BinarySection.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/BinarySection.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" diff --git a/bolt/src/MCPlusBuilder.cpp b/bolt/lib/Core/MCPlusBuilder.cpp similarity index 99% rename from bolt/src/MCPlusBuilder.cpp rename to bolt/lib/Core/MCPlusBuilder.cpp index 909cfd09bd39..452c966c8693 100644 --- a/bolt/src/MCPlusBuilder.cpp +++ b/bolt/lib/Core/MCPlusBuilder.cpp @@ -10,10 +10,10 @@ // //===----------------------------------------------------------------------===// -#include "MCPlus.h" -#include "MCPlusBuilder.h" -#include "llvm/MC/MCInstrAnalysis.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Core/MCPlus.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCInstrAnalysis.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/Support/Debug.h" diff --git a/bolt/src/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp similarity index 98% rename from bolt/src/ParallelUtilities.cpp rename to bolt/lib/Core/ParallelUtilities.cpp index 1fc0935c36a9..b29bfd18b006 100644 --- a/bolt/src/ParallelUtilities.cpp +++ b/bolt/lib/Core/ParallelUtilities.cpp @@ -1,4 +1,4 @@ -//===--- ParallelUtilities.cpp -------------------------------------------===// +//===--- ParallelUtilities.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "ParallelUtilities.h" -#include "BinaryContext.h" -#include "BinaryFunction.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Support/Timer.h" #include diff --git a/bolt/src/Relocation.cpp b/bolt/lib/Core/Relocation.cpp similarity index 99% rename from bolt/src/Relocation.cpp rename to bolt/lib/Core/Relocation.cpp index f86336ef5fa4..b0024d9daaa2 100644 --- a/bolt/src/Relocation.cpp +++ b/bolt/lib/Core/Relocation.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "Relocation.h" +#include "bolt/Core/Relocation.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCStreamer.h" diff --git a/bolt/src/Passes/ADRRelaxationPass.cpp b/bolt/lib/Passes/ADRRelaxationPass.cpp similarity index 96% rename from bolt/src/Passes/ADRRelaxationPass.cpp rename to bolt/lib/Passes/ADRRelaxationPass.cpp index 5f12465d490c..4d2bcc4e1398 100644 --- a/bolt/src/Passes/ADRRelaxationPass.cpp +++ b/bolt/lib/Passes/ADRRelaxationPass.cpp @@ -9,8 +9,8 @@ // //===----------------------------------------------------------------------===// -#include "ADRRelaxationPass.h" -#include "ParallelUtilities.h" +#include "bolt/Passes/ADRRelaxationPass.h" +#include "bolt/Core/ParallelUtilities.h" using namespace llvm; diff --git a/bolt/src/Passes/Aligner.cpp b/bolt/lib/Passes/Aligner.cpp similarity index 98% rename from bolt/src/Passes/Aligner.cpp rename to bolt/lib/Passes/Aligner.cpp index 8d21c6085503..4ffa0e1c9886 100644 --- a/bolt/src/Passes/Aligner.cpp +++ b/bolt/lib/Passes/Aligner.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "Aligner.h" -#include "ParallelUtilities.h" +#include "bolt/Passes/Aligner.h" +#include "bolt/Core/ParallelUtilities.h" #define DEBUG_TYPE "bolt-aligner" diff --git a/bolt/src/Passes/AllocCombiner.cpp b/bolt/lib/Passes/AllocCombiner.cpp similarity index 98% rename from bolt/src/Passes/AllocCombiner.cpp rename to bolt/lib/Passes/AllocCombiner.cpp index 57b22d894593..ee7d20327802 100644 --- a/bolt/src/Passes/AllocCombiner.cpp +++ b/bolt/lib/Passes/AllocCombiner.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "AllocCombiner.h" +#include "bolt/Passes/AllocCombiner.h" #define DEBUG_TYPE "alloccombiner" diff --git a/bolt/src/Passes/BinaryFunctionCallGraph.cpp b/bolt/lib/Passes/BinaryFunctionCallGraph.cpp similarity index 98% rename from bolt/src/Passes/BinaryFunctionCallGraph.cpp rename to bolt/lib/Passes/BinaryFunctionCallGraph.cpp index ddf15e70526f..6f8b4577de86 100644 --- a/bolt/src/Passes/BinaryFunctionCallGraph.cpp +++ b/bolt/lib/Passes/BinaryFunctionCallGraph.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "BinaryFunctionCallGraph.h" -#include "BinaryFunction.h" -#include "BinaryContext.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Timer.h" #include diff --git a/bolt/src/Passes/BinaryPasses.cpp b/bolt/lib/Passes/BinaryPasses.cpp similarity index 98% rename from bolt/src/Passes/BinaryPasses.cpp rename to bolt/lib/Passes/BinaryPasses.cpp index 4c505a463a70..33c95c2cb302 100644 --- a/bolt/src/Passes/BinaryPasses.cpp +++ b/bolt/lib/Passes/BinaryPasses.cpp @@ -8,10 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "BinaryPasses.h" -#include "ParallelUtilities.h" -#include "Passes/ReorderAlgorithm.h" -#include "Passes/ReorderFunctions.h" +#include "bolt/Passes/BinaryPasses.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Passes/ReorderAlgorithm.h" +#include "bolt/Passes/ReorderFunctions.h" #include "llvm/Support/CommandLine.h" #include @@ -58,9 +58,9 @@ extern cl::OptionCategory BoltOptCategory; extern cl::opt AlignMacroOpFusion; extern cl::opt Verbosity; extern cl::opt EnableBAT; +extern cl::opt ExecutionCountThreshold; extern cl::opt UpdateDebugSections; extern cl::opt ReorderFunctions; -extern bool isHotTextMover(const bolt::BinaryFunction &Function); enum DynoStatsSortOrder : char { Ascending, @@ -75,6 +75,26 @@ DynoStatsSortOrderOpt("print-sorted-by-order", cl::init(DynoStatsSortOrder::Descending), cl::cat(BoltOptCategory)); +cl::list +HotTextMoveSections("hot-text-move-sections", + cl::desc("list of sections containing functions used for hugifying hot text. " + "BOLT makes sure these functions are not placed on the same page as " + "the hot text. (default=\'.stub,.mover\')."), + cl::value_desc("sec1,sec2,sec3,..."), + cl::CommaSeparated, + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +bool isHotTextMover(const BinaryFunction &Function) { + for (std::string &SectionName : opts::HotTextMoveSections) { + if (Function.getOriginSectionName() && + *Function.getOriginSectionName() == SectionName) + return true; + } + + return false; +} + static cl::opt MinBranchClusters("min-branch-clusters", cl::desc("use a modified clustering algorithm geared towards minimizing " @@ -174,15 +194,6 @@ cl::opt ReorderBlocks( "cluster-shuffle", "perform random layout of clusters")), cl::ZeroOrMore, cl::cat(BoltOptCategory)); -cl::opt -ExecutionCountThreshold("execution-count-threshold", - cl::desc("perform profiling accuracy-sensitive optimizations only if " - "function execution count >= the threshold (default: 0)"), - cl::init(0), - cl::ZeroOrMore, - cl::Hidden, - cl::cat(BoltOptCategory)); - static cl::opt ReportBadLayout("report-bad-layout", cl::desc("print top functions with suboptimal code layout on input"), diff --git a/bolt/src/Passes/CMakeLists.txt b/bolt/lib/Passes/CMakeLists.txt similarity index 89% rename from bolt/src/Passes/CMakeLists.txt rename to bolt/lib/Passes/CMakeLists.txt index b03f03d7dfbf..25eda16d4710 100644 --- a/bolt/src/Passes/CMakeLists.txt +++ b/bolt/lib/Passes/CMakeLists.txt @@ -4,6 +4,7 @@ add_llvm_library(LLVMBOLTPasses AllocCombiner.cpp BinaryPasses.cpp BinaryFunctionCallGraph.cpp + CacheMetrics.cpp CallGraph.cpp CallGraphWalker.cpp DataflowAnalysis.cpp @@ -43,8 +44,12 @@ add_llvm_library(LLVMBOLTPasses VeneerElimination.cpp RetpolineInsertion.cpp - DEPENDS - intrinsics_gen - ) + LINK_LIBS + ${LLVM_PTHREAD_LIB} -include_directories( ${BOLT_SOURCE_DIR}/src ) + LINK_COMPONENTS + BOLTCore + BOLTUtils + MC + Support + ) diff --git a/bolt/src/CacheMetrics.cpp b/bolt/lib/Passes/CacheMetrics.cpp similarity index 99% rename from bolt/src/CacheMetrics.cpp rename to bolt/lib/Passes/CacheMetrics.cpp index 3bb1cf520085..21e2657d3984 100644 --- a/bolt/src/CacheMetrics.cpp +++ b/bolt/lib/Passes/CacheMetrics.cpp @@ -10,9 +10,9 @@ // //===----------------------------------------------------------------------===// -#include "CacheMetrics.h" -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" +#include "bolt/Passes/CacheMetrics.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/CallGraph.cpp b/bolt/lib/Passes/CallGraph.cpp similarity index 99% rename from bolt/src/Passes/CallGraph.cpp rename to bolt/lib/Passes/CallGraph.cpp index 3693c38e1eef..b8981a00e8f7 100644 --- a/bolt/src/Passes/CallGraph.cpp +++ b/bolt/lib/Passes/CallGraph.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "CallGraph.h" +#include "bolt/Passes/CallGraph.h" #define DEBUG_TYPE "callgraph" diff --git a/bolt/src/Passes/CallGraphWalker.cpp b/bolt/lib/Passes/CallGraphWalker.cpp similarity index 94% rename from bolt/src/Passes/CallGraphWalker.cpp rename to bolt/lib/Passes/CallGraphWalker.cpp index e3f26e47ab6f..1033097293b6 100644 --- a/bolt/src/Passes/CallGraphWalker.cpp +++ b/bolt/lib/Passes/CallGraphWalker.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "CallGraphWalker.h" -#include "BinaryFunctionCallGraph.h" +#include "bolt/Passes/CallGraphWalker.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Timer.h" #include diff --git a/bolt/src/Passes/DataflowAnalysis.cpp b/bolt/lib/Passes/DataflowAnalysis.cpp similarity index 98% rename from bolt/src/Passes/DataflowAnalysis.cpp rename to bolt/lib/Passes/DataflowAnalysis.cpp index d2d4707cd0fc..f297f668d4f2 100644 --- a/bolt/src/Passes/DataflowAnalysis.cpp +++ b/bolt/lib/Passes/DataflowAnalysis.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "DataflowAnalysis.h" +#include "bolt/Passes/DataflowAnalysis.h" #define DEBUG_TYPE "dataflow" diff --git a/bolt/src/Passes/DataflowInfoManager.cpp b/bolt/lib/Passes/DataflowInfoManager.cpp similarity index 98% rename from bolt/src/Passes/DataflowInfoManager.cpp rename to bolt/lib/Passes/DataflowInfoManager.cpp index 27977ed8c481..4bfa227c3c02 100644 --- a/bolt/src/Passes/DataflowInfoManager.cpp +++ b/bolt/lib/Passes/DataflowInfoManager.cpp @@ -8,8 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "DataflowInfoManager.h" - +#include "bolt/Passes/DataflowInfoManager.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp b/bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp similarity index 99% rename from bolt/src/Passes/ExtTSPReorderAlgorithm.cpp rename to bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp index f2f9c6cbe0fb..304125577485 100644 --- a/bolt/src/Passes/ExtTSPReorderAlgorithm.cpp +++ b/bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp @@ -29,9 +29,9 @@ // IEEE Transactions on Computers, 2020 // https://arxiv.org/abs/1809.04676 //===----------------------------------------------------------------------===// -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" -#include "ReorderAlgorithm.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/ReorderAlgorithm.h" #include "llvm/Support/CommandLine.h" using namespace llvm; diff --git a/bolt/src/Passes/FrameAnalysis.cpp b/bolt/lib/Passes/FrameAnalysis.cpp similarity index 99% rename from bolt/src/Passes/FrameAnalysis.cpp rename to bolt/lib/Passes/FrameAnalysis.cpp index c9fb1855042c..6ee5fa06c678 100644 --- a/bolt/src/Passes/FrameAnalysis.cpp +++ b/bolt/lib/Passes/FrameAnalysis.cpp @@ -1,4 +1,4 @@ -//===--- Passes/FrameAnalysis.h -------------------------------------------===// +//===--- Passes/FrameAnalysis.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// -#include "FrameAnalysis.h" -#include "CallGraphWalker.h" -#include "ParallelUtilities.h" +#include "bolt/Passes/FrameAnalysis.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Passes/CallGraphWalker.h" #include "llvm/Support/Timer.h" #include #include diff --git a/bolt/src/Passes/FrameOptimizer.cpp b/bolt/lib/Passes/FrameOptimizer.cpp similarity index 97% rename from bolt/src/Passes/FrameOptimizer.cpp rename to bolt/lib/Passes/FrameOptimizer.cpp index 013e759a96c5..0a7b4ede00eb 100644 --- a/bolt/src/Passes/FrameOptimizer.cpp +++ b/bolt/lib/Passes/FrameOptimizer.cpp @@ -8,13 +8,13 @@ // //===----------------------------------------------------------------------===// -#include "FrameOptimizer.h" -#include "BinaryFunctionCallGraph.h" -#include "DataflowInfoManager.h" -#include "ParallelUtilities.h" -#include "ShrinkWrapping.h" -#include "StackAvailableExpressions.h" -#include "StackReachingUses.h" +#include "bolt/Passes/FrameOptimizer.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/DataflowInfoManager.h" +#include "bolt/Passes/ShrinkWrapping.h" +#include "bolt/Passes/StackAvailableExpressions.h" +#include "bolt/Passes/StackReachingUses.h" #include "llvm/Support/Timer.h" #include #include diff --git a/bolt/src/Passes/HFSort.cpp b/bolt/lib/Passes/HFSort.cpp similarity index 99% rename from bolt/src/Passes/HFSort.cpp rename to bolt/lib/Passes/HFSort.cpp index 166455d23925..328bcf770567 100644 --- a/bolt/src/Passes/HFSort.cpp +++ b/bolt/lib/Passes/HFSort.cpp @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -#include "HFSort.h" +#include "bolt/Passes/HFSort.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" diff --git a/bolt/src/Passes/HFSortPlus.cpp b/bolt/lib/Passes/HFSortPlus.cpp similarity index 99% rename from bolt/src/Passes/HFSortPlus.cpp rename to bolt/lib/Passes/HFSortPlus.cpp index 8c2f01c4ed6b..57a0a756f96e 100644 --- a/bolt/src/Passes/HFSortPlus.cpp +++ b/bolt/lib/Passes/HFSortPlus.cpp @@ -22,7 +22,7 @@ // page. The following algorithm detects short and long calls, and optimizes // the expected number of cache misses for the long ones. -#include "HFSort.h" +#include "bolt/Passes/HFSort.h" #include "llvm/Support/CommandLine.h" #include #include diff --git a/bolt/src/Passes/IdenticalCodeFolding.cpp b/bolt/lib/Passes/IdenticalCodeFolding.cpp similarity index 99% rename from bolt/src/Passes/IdenticalCodeFolding.cpp rename to bolt/lib/Passes/IdenticalCodeFolding.cpp index e9b0dd0b23c6..c31e8f4bab9f 100644 --- a/bolt/src/Passes/IdenticalCodeFolding.cpp +++ b/bolt/lib/Passes/IdenticalCodeFolding.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "Passes/IdenticalCodeFolding.h" -#include "ParallelUtilities.h" +#include "bolt/Passes/IdenticalCodeFolding.h" +#include "bolt/Core/ParallelUtilities.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Support/Timer.h" diff --git a/bolt/src/Passes/IndirectCallPromotion.cpp b/bolt/lib/Passes/IndirectCallPromotion.cpp similarity index 98% rename from bolt/src/Passes/IndirectCallPromotion.cpp rename to bolt/lib/Passes/IndirectCallPromotion.cpp index 1dc4eba4b9df..7f7af2a1f7aa 100644 --- a/bolt/src/Passes/IndirectCallPromotion.cpp +++ b/bolt/lib/Passes/IndirectCallPromotion.cpp @@ -8,9 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "IndirectCallPromotion.h" -#include "BinaryFunctionCallGraph.h" -#include "DataflowInfoManager.h" +#include "bolt/Passes/IndirectCallPromotion.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/DataflowInfoManager.h" +#include "bolt/Utils/CommandLineOpts.h" #include "llvm/Support/CommandLine.h" #define DEBUG_TYPE "ICP" @@ -23,21 +24,10 @@ namespace opts { extern cl::OptionCategory BoltOptCategory; +extern cl::opt IndirectCallPromotion; extern cl::opt Verbosity; extern cl::opt ExecutionCountThreshold; -cl::opt -IndirectCallPromotion("indirect-call-promotion", - cl::init(ICP_NONE), - cl::desc("indirect call promotion"), - cl::values( - clEnumValN(ICP_NONE, "none", "do not perform indirect call promotion"), - clEnumValN(ICP_CALLS, "calls", "perform ICP on indirect calls"), - clEnumValN(ICP_JUMP_TABLES, "jump-tables", "perform ICP on jump tables"), - clEnumValN(ICP_ALL, "all", "perform ICP on calls and jump tables")), - cl::ZeroOrMore, - cl::cat(BoltOptCategory)); - static cl::opt ICPJTRemainingPercentThreshold( "icp-jt-remaining-percent-threshold", diff --git a/bolt/src/Passes/Inliner.cpp b/bolt/lib/Passes/Inliner.cpp similarity index 99% rename from bolt/src/Passes/Inliner.cpp rename to bolt/lib/Passes/Inliner.cpp index 1eb243800dbf..163ef55d62c4 100644 --- a/bolt/src/Passes/Inliner.cpp +++ b/bolt/lib/Passes/Inliner.cpp @@ -22,8 +22,8 @@ // //===----------------------------------------------------------------------===// -#include "Inliner.h" -#include "MCPlus.h" +#include "bolt/Passes/Inliner.h" +#include "bolt/Core/MCPlus.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp similarity index 99% rename from bolt/src/Passes/Instrumentation.cpp rename to bolt/lib/Passes/Instrumentation.cpp index 5531b216a85b..4f5d2b46a8b2 100644 --- a/bolt/src/Passes/Instrumentation.cpp +++ b/bolt/lib/Passes/Instrumentation.cpp @@ -8,10 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "Instrumentation.h" -#include "ParallelUtilities.h" -#include "RuntimeLibs/InstrumentationRuntimeLibrary.h" -#include "Utils.h" +#include "bolt/Passes/Instrumentation.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h" +#include "bolt/Utils/Utils.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/JTFootprintReduction.cpp b/bolt/lib/Passes/JTFootprintReduction.cpp similarity index 98% rename from bolt/src/Passes/JTFootprintReduction.cpp rename to bolt/lib/Passes/JTFootprintReduction.cpp index 6dc52fbbac6a..fc22648f9690 100644 --- a/bolt/src/Passes/JTFootprintReduction.cpp +++ b/bolt/lib/Passes/JTFootprintReduction.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "JTFootprintReduction.h" -#include "BinaryFunctionCallGraph.h" -#include "DataflowInfoManager.h" +#include "bolt/Passes/JTFootprintReduction.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/DataflowInfoManager.h" #include "llvm/Support/CommandLine.h" #define DEBUG_TYPE "JT" diff --git a/bolt/src/Passes/LivenessAnalysis.cpp b/bolt/lib/Passes/LivenessAnalysis.cpp similarity index 93% rename from bolt/src/Passes/LivenessAnalysis.cpp rename to bolt/lib/Passes/LivenessAnalysis.cpp index 8ef08f40d76b..b622179ea7ce 100644 --- a/bolt/src/Passes/LivenessAnalysis.cpp +++ b/bolt/lib/Passes/LivenessAnalysis.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// -#include "LivenessAnalysis.h" +#include "bolt/Passes/LivenessAnalysis.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/LongJmp.cpp b/bolt/lib/Passes/LongJmp.cpp similarity index 99% rename from bolt/src/Passes/LongJmp.cpp rename to bolt/lib/Passes/LongJmp.cpp index 199e1254fa52..cd66fb7d6ba5 100644 --- a/bolt/src/Passes/LongJmp.cpp +++ b/bolt/lib/Passes/LongJmp.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "LongJmp.h" +#include "bolt/Passes/LongJmp.h" #include "llvm/Support/Alignment.h" #define DEBUG_TYPE "longjmp" diff --git a/bolt/src/Passes/LoopInversionPass.cpp b/bolt/lib/Passes/LoopInversionPass.cpp similarity index 97% rename from bolt/src/Passes/LoopInversionPass.cpp rename to bolt/lib/Passes/LoopInversionPass.cpp index 83d0b1369d1d..44a1b37e2f64 100644 --- a/bolt/src/Passes/LoopInversionPass.cpp +++ b/bolt/lib/Passes/LoopInversionPass.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "LoopInversionPass.h" -#include "ParallelUtilities.h" +#include "bolt/Passes/LoopInversionPass.h" +#include "bolt/Core/ParallelUtilities.h" using namespace llvm; diff --git a/bolt/src/Passes/MCF.cpp b/bolt/lib/Passes/MCF.cpp similarity index 99% rename from bolt/src/Passes/MCF.cpp rename to bolt/lib/Passes/MCF.cpp index 2e540821393d..eb6608d64007 100644 --- a/bolt/src/Passes/MCF.cpp +++ b/bolt/lib/Passes/MCF.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "MCF.h" -#include "BinaryFunction.h" -#include "Passes/DataflowInfoManager.h" +#include "bolt/Passes/MCF.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/DataflowInfoManager.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/PLTCall.cpp b/bolt/lib/Passes/PLTCall.cpp similarity index 98% rename from bolt/src/Passes/PLTCall.cpp rename to bolt/lib/Passes/PLTCall.cpp index b6874499e75f..4fd44ba04014 100644 --- a/bolt/src/Passes/PLTCall.cpp +++ b/bolt/lib/Passes/PLTCall.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "PLTCall.h" +#include "bolt/Passes/PLTCall.h" #include "llvm/Support/CommandLine.h" #define DEBUG_TYPE "bolt-plt" diff --git a/bolt/src/Passes/PatchEntries.cpp b/bolt/lib/Passes/PatchEntries.cpp similarity index 98% rename from bolt/src/Passes/PatchEntries.cpp rename to bolt/lib/Passes/PatchEntries.cpp index e2cf01422550..a0f64065b5bb 100644 --- a/bolt/src/Passes/PatchEntries.cpp +++ b/bolt/lib/Passes/PatchEntries.cpp @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#include "PatchEntries.h" -#include "NameResolver.h" +#include "bolt/Passes/PatchEntries.h" +#include "bolt/Utils/NameResolver.h" #include "llvm/Support/CommandLine.h" namespace opts { diff --git a/bolt/src/Passes/PettisAndHansen.cpp b/bolt/lib/Passes/PettisAndHansen.cpp similarity index 99% rename from bolt/src/Passes/PettisAndHansen.cpp rename to bolt/lib/Passes/PettisAndHansen.cpp index 08030ecc3e02..fe4bba6e8c6a 100644 --- a/bolt/src/Passes/PettisAndHansen.cpp +++ b/bolt/lib/Passes/PettisAndHansen.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "HFSort.h" +#include "bolt/Passes/HFSort.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" diff --git a/bolt/src/Passes/RegAnalysis.cpp b/bolt/lib/Passes/RegAnalysis.cpp similarity index 98% rename from bolt/src/Passes/RegAnalysis.cpp rename to bolt/lib/Passes/RegAnalysis.cpp index 40138ece8e69..6f28d48c94e6 100644 --- a/bolt/src/Passes/RegAnalysis.cpp +++ b/bolt/lib/Passes/RegAnalysis.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "RegAnalysis.h" -#include "BinaryFunction.h" -#include "CallGraphWalker.h" +#include "bolt/Passes/RegAnalysis.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/CallGraphWalker.h" #include "llvm/Support/CommandLine.h" #define DEBUG_TYPE "ra" diff --git a/bolt/src/Passes/RegReAssign.cpp b/bolt/lib/Passes/RegReAssign.cpp similarity index 98% rename from bolt/src/Passes/RegReAssign.cpp rename to bolt/lib/Passes/RegReAssign.cpp index f772e368c7f8..9be2bbaa80c9 100644 --- a/bolt/src/Passes/RegReAssign.cpp +++ b/bolt/lib/Passes/RegReAssign.cpp @@ -8,12 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "RegReAssign.h" -#include "BinaryFunctionCallGraph.h" -#include "DataflowAnalysis.h" -#include "DataflowInfoManager.h" -#include "MCPlus.h" -#include "Utils.h" +#include "bolt/Passes/RegReAssign.h" +#include "bolt/Core/MCPlus.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/DataflowAnalysis.h" +#include "bolt/Passes/DataflowInfoManager.h" +#include "bolt/Utils/Utils.h" #include #define DEBUG_TYPE "regreassign" diff --git a/bolt/src/Passes/ReorderAlgorithm.cpp b/bolt/lib/Passes/ReorderAlgorithm.cpp similarity index 99% rename from bolt/src/Passes/ReorderAlgorithm.cpp rename to bolt/lib/Passes/ReorderAlgorithm.cpp index e4f73290c9c0..1718caed0c08 100644 --- a/bolt/src/Passes/ReorderAlgorithm.cpp +++ b/bolt/lib/Passes/ReorderAlgorithm.cpp @@ -10,9 +10,9 @@ // //===----------------------------------------------------------------------===// -#include "ReorderAlgorithm.h" -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" +#include "bolt/Passes/ReorderAlgorithm.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/CommandLine.h" #include #include diff --git a/bolt/src/Passes/ReorderData.cpp b/bolt/lib/Passes/ReorderData.cpp similarity index 99% rename from bolt/src/Passes/ReorderData.cpp rename to bolt/lib/Passes/ReorderData.cpp index 54027937f5ff..4dac2454125e 100644 --- a/bolt/src/Passes/ReorderData.cpp +++ b/bolt/lib/Passes/ReorderData.cpp @@ -12,7 +12,7 @@ // - make sure writeable data isn't put on same cache line unless temporally local // - estimate temporal locality by looking at CFG? -#include "ReorderData.h" +#include "bolt/Passes/ReorderData.h" #include #undef DEBUG_TYPE diff --git a/bolt/src/Passes/ReorderFunctions.cpp b/bolt/lib/Passes/ReorderFunctions.cpp similarity index 99% rename from bolt/src/Passes/ReorderFunctions.cpp rename to bolt/lib/Passes/ReorderFunctions.cpp index a80312d46b10..95bdc9e1e93c 100644 --- a/bolt/src/Passes/ReorderFunctions.cpp +++ b/bolt/lib/Passes/ReorderFunctions.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "ReorderFunctions.h" -#include "HFSort.h" +#include "bolt/Passes/ReorderFunctions.h" +#include "bolt/Passes/HFSort.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp similarity index 99% rename from bolt/src/Passes/RetpolineInsertion.cpp rename to bolt/lib/Passes/RetpolineInsertion.cpp index 4cdc457b8ebb..09d7da7d09ba 100644 --- a/bolt/src/Passes/RetpolineInsertion.cpp +++ b/bolt/lib/Passes/RetpolineInsertion.cpp @@ -19,7 +19,7 @@ // Adding lfence instruction to the body of the speculate code is enabled by // default and can be controlled by the user using retpoline-lfence option. //===----------------------------------------------------------------------===// -#include "RetpolineInsertion.h" +#include "bolt/Passes/RetpolineInsertion.h" #include "llvm/Support/raw_ostream.h" #define DEBUG_TYPE "bolt-retpoline" diff --git a/bolt/src/Passes/ShrinkWrapping.cpp b/bolt/lib/Passes/ShrinkWrapping.cpp similarity index 99% rename from bolt/src/Passes/ShrinkWrapping.cpp rename to bolt/lib/Passes/ShrinkWrapping.cpp index 11440e720510..b23a7aa96551 100644 --- a/bolt/src/Passes/ShrinkWrapping.cpp +++ b/bolt/lib/Passes/ShrinkWrapping.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "ShrinkWrapping.h" -#include "DataflowInfoManager.h" -#include "MCPlus.h" +#include "bolt/Passes/ShrinkWrapping.h" +#include "bolt/Core/MCPlus.h" +#include "bolt/Passes/DataflowInfoManager.h" #include #include diff --git a/bolt/src/Passes/SplitFunctions.cpp b/bolt/lib/Passes/SplitFunctions.cpp similarity index 98% rename from bolt/src/Passes/SplitFunctions.cpp rename to bolt/lib/Passes/SplitFunctions.cpp index 2c369d74ede2..b2804bf0d3d6 100644 --- a/bolt/src/Passes/SplitFunctions.cpp +++ b/bolt/lib/Passes/SplitFunctions.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "BinaryFunction.h" -#include "ParallelUtilities.h" -#include "SplitFunctions.h" +#include "bolt/Passes/SplitFunctions.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/ParallelUtilities.h" #include "llvm/Support/CommandLine.h" #include diff --git a/bolt/src/Passes/StackAllocationAnalysis.cpp b/bolt/lib/Passes/StackAllocationAnalysis.cpp similarity index 98% rename from bolt/src/Passes/StackAllocationAnalysis.cpp rename to bolt/lib/Passes/StackAllocationAnalysis.cpp index c09cbce7d0e6..17e6d434f120 100644 --- a/bolt/src/Passes/StackAllocationAnalysis.cpp +++ b/bolt/lib/Passes/StackAllocationAnalysis.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "StackAllocationAnalysis.h" -#include "StackPointerTracking.h" +#include "bolt/Passes/StackAllocationAnalysis.h" +#include "bolt/Passes/StackPointerTracking.h" #include "llvm/Support/Debug.h" #define DEBUG_TYPE "saa" diff --git a/bolt/src/Passes/StackAvailableExpressions.cpp b/bolt/lib/Passes/StackAvailableExpressions.cpp similarity index 97% rename from bolt/src/Passes/StackAvailableExpressions.cpp rename to bolt/lib/Passes/StackAvailableExpressions.cpp index 5f2c1ad36862..8d5727630ef2 100644 --- a/bolt/src/Passes/StackAvailableExpressions.cpp +++ b/bolt/lib/Passes/StackAvailableExpressions.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "StackAvailableExpressions.h" -#include "FrameAnalysis.h" -#include "RegAnalysis.h" +#include "bolt/Passes/StackAvailableExpressions.h" +#include "bolt/Passes/FrameAnalysis.h" +#include "bolt/Passes/RegAnalysis.h" #define DEBUG_TYPE "sae" diff --git a/bolt/src/Passes/StackPointerTracking.cpp b/bolt/lib/Passes/StackPointerTracking.cpp similarity index 95% rename from bolt/src/Passes/StackPointerTracking.cpp rename to bolt/lib/Passes/StackPointerTracking.cpp index 8e679b46257f..5e4ae8ecde74 100644 --- a/bolt/src/Passes/StackPointerTracking.cpp +++ b/bolt/lib/Passes/StackPointerTracking.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "StackPointerTracking.h" +#include "bolt/Passes/StackPointerTracking.h" namespace llvm { namespace bolt { diff --git a/bolt/src/Passes/StackReachingUses.cpp b/bolt/lib/Passes/StackReachingUses.cpp similarity index 98% rename from bolt/src/Passes/StackReachingUses.cpp rename to bolt/lib/Passes/StackReachingUses.cpp index 268fe6d634fc..9c7ee3651f70 100644 --- a/bolt/src/Passes/StackReachingUses.cpp +++ b/bolt/lib/Passes/StackReachingUses.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// -#include "StackReachingUses.h" -#include "FrameAnalysis.h" +#include "bolt/Passes/StackReachingUses.h" +#include "bolt/Passes/FrameAnalysis.h" #define DEBUG_TYPE "sru" diff --git a/bolt/src/Passes/StokeInfo.cpp b/bolt/lib/Passes/StokeInfo.cpp similarity index 97% rename from bolt/src/Passes/StokeInfo.cpp rename to bolt/lib/Passes/StokeInfo.cpp index f203238be9d8..1b7e50836ea8 100644 --- a/bolt/src/Passes/StokeInfo.cpp +++ b/bolt/lib/Passes/StokeInfo.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "StokeInfo.h" -#include "BinaryFunctionCallGraph.h" -#include "DataflowInfoManager.h" +#include "bolt/Passes/StokeInfo.h" +#include "bolt/Passes/BinaryFunctionCallGraph.h" +#include "bolt/Passes/DataflowInfoManager.h" #include "llvm/Support/CommandLine.h" #undef DEBUG_TYPE diff --git a/bolt/src/Passes/TailDuplication.cpp b/bolt/lib/Passes/TailDuplication.cpp similarity index 99% rename from bolt/src/Passes/TailDuplication.cpp rename to bolt/lib/Passes/TailDuplication.cpp index 1d1af814e9eb..05c77b63a919 100644 --- a/bolt/src/Passes/TailDuplication.cpp +++ b/bolt/lib/Passes/TailDuplication.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "TailDuplication.h" +#include "bolt/Passes/TailDuplication.h" #include diff --git a/bolt/src/Passes/ThreeWayBranch.cpp b/bolt/lib/Passes/ThreeWayBranch.cpp similarity index 99% rename from bolt/src/Passes/ThreeWayBranch.cpp rename to bolt/lib/Passes/ThreeWayBranch.cpp index 56cf2ff87e20..32c72d6c6a3d 100644 --- a/bolt/src/Passes/ThreeWayBranch.cpp +++ b/bolt/lib/Passes/ThreeWayBranch.cpp @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -#include "ThreeWayBranch.h" +#include "bolt/Passes/ThreeWayBranch.h" #include diff --git a/bolt/src/Passes/ValidateInternalCalls.cpp b/bolt/lib/Passes/ValidateInternalCalls.cpp similarity index 98% rename from bolt/src/Passes/ValidateInternalCalls.cpp rename to bolt/lib/Passes/ValidateInternalCalls.cpp index 2a91b9b6972b..68f664ac51b8 100644 --- a/bolt/src/Passes/ValidateInternalCalls.cpp +++ b/bolt/lib/Passes/ValidateInternalCalls.cpp @@ -8,9 +8,9 @@ // //===----------------------------------------------------------------------===// -#include "ValidateInternalCalls.h" -#include "FrameAnalysis.h" -#include "Passes/DataflowInfoManager.h" +#include "bolt/Passes/ValidateInternalCalls.h" +#include "bolt/Passes/DataflowInfoManager.h" +#include "bolt/Passes/FrameAnalysis.h" #include "llvm/MC/MCInstPrinter.h" #define DEBUG_TYPE "bolt-internalcalls" diff --git a/bolt/src/Passes/VeneerElimination.cpp b/bolt/lib/Passes/VeneerElimination.cpp similarity index 98% rename from bolt/src/Passes/VeneerElimination.cpp rename to bolt/lib/Passes/VeneerElimination.cpp index 1270d156d56b..62b4512b9b38 100644 --- a/bolt/src/Passes/VeneerElimination.cpp +++ b/bolt/lib/Passes/VeneerElimination.cpp @@ -10,7 +10,7 @@ // code and redirects veneer callers to call to veneers destinations // //===----------------------------------------------------------------------===// -#include "VeneerElimination.h" +#include "bolt/Passes/VeneerElimination.h" #define DEBUG_TYPE "veneer-elim" using namespace llvm; diff --git a/bolt/src/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp similarity index 99% rename from bolt/src/BoltAddressTranslation.cpp rename to bolt/lib/Profile/BoltAddressTranslation.cpp index 698a414f1d31..0f6b699a95cc 100644 --- a/bolt/src/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// -#include "BoltAddressTranslation.h" -#include "BinaryFunction.h" +#include "bolt/Profile/BoltAddressTranslation.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Errc.h" diff --git a/bolt/lib/Profile/CMakeLists.txt b/bolt/lib/Profile/CMakeLists.txt new file mode 100644 index 000000000000..b1501968eb65 --- /dev/null +++ b/bolt/lib/Profile/CMakeLists.txt @@ -0,0 +1,15 @@ +add_llvm_library(LLVMBOLTProfile + BoltAddressTranslation.cpp + DataAggregator.cpp + DataReader.cpp + Heatmap.cpp + ProfileReaderBase.cpp + YAMLProfileReader.cpp + YAMLProfileWriter.cpp + + LINK_COMPONENTS + BOLTCore + BOLTPasses + BOLTUtils + Support + ) diff --git a/bolt/src/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp similarity index 98% rename from bolt/src/DataAggregator.cpp rename to bolt/lib/Profile/DataAggregator.cpp index d9abf3f8e992..954728fc3286 100644 --- a/bolt/src/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -11,20 +11,21 @@ // //===----------------------------------------------------------------------===// -#include "BinaryContext.h" -#include "BinaryFunction.h" -#include "BoltAddressTranslation.h" -#include "DataAggregator.h" -#include "Heatmap.h" -#include "Utils.h" +#include "bolt/Profile/DataAggregator.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Profile/BoltAddressTranslation.h" +#include "bolt/Profile/Heatmap.h" +#include "bolt/Utils/CommandLineOpts.h" +#include "bolt/Utils/Utils.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Timer.h" +#include "llvm/Support/raw_ostream.h" #include #include @@ -37,13 +38,6 @@ using namespace bolt; namespace opts { -extern cl::OptionCategory AggregatorCategory; -extern bool HeatmapMode; -extern bool LinuxKernelMode; -extern cl::SubCommand HeatmapCommand; -extern cl::opt AggregateOnly; -extern cl::opt OutputFilename; - static cl::opt BasicAggregation("nl", cl::desc("aggregate basic samples (without LBR info)"), @@ -65,33 +59,6 @@ FilterPID("pid", cl::Optional, cl::cat(AggregatorCategory)); -static cl::opt -HeatmapBlock("block-size", - cl::desc("size of a heat map block in bytes (default 64)"), - cl::init(64), - cl::sub(HeatmapCommand)); - -static cl::opt -HeatmapFile("o", - cl::init("-"), - cl::desc("heatmap output file (default stdout)"), - cl::Optional, - cl::sub(HeatmapCommand)); - -static cl::opt -HeatmapMaxAddress("max-address", - cl::init(0xffffffff), - cl::desc("maximum address considered valid for heatmap (default 4GB)"), - cl::Optional, - cl::sub(HeatmapCommand)); - -static cl::opt -HeatmapMinAddress("min-address", - cl::init(0x0), - cl::desc("minimum address considered valid for heatmap (default 0)"), - cl::Optional, - cl::sub(HeatmapCommand)); - static cl::opt IgnoreBuildID("ignore-build-id", cl::desc("continue even if build-ids in input binary and perf.data mismatch"), diff --git a/bolt/src/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp similarity index 99% rename from bolt/src/DataReader.cpp rename to bolt/lib/Profile/DataReader.cpp index 9ceebda344a6..a3d213e2d027 100644 --- a/bolt/src/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "DataReader.h" -#include "BinaryFunction.h" -#include "Passes/MCF.h" -#include "Utils.h" +#include "bolt/Profile/DataReader.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/MCF.h" +#include "bolt/Utils/Utils.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include diff --git a/bolt/src/Heatmap.cpp b/bolt/lib/Profile/Heatmap.cpp similarity index 96% rename from bolt/src/Heatmap.cpp rename to bolt/lib/Profile/Heatmap.cpp index c9b497b820df..14a5ab6bf08d 100644 --- a/bolt/src/Heatmap.cpp +++ b/bolt/lib/Profile/Heatmap.cpp @@ -8,7 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "Heatmap.h" +#include "bolt/Profile/Heatmap.h" +#include "bolt/Utils/CommandLineOpts.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -24,19 +25,6 @@ using namespace llvm; -namespace opts { - -extern cl::SubCommand HeatmapCommand; - -static cl::opt -BucketsPerLine("line-size", - cl::desc("number of entries per line (default 256)"), - cl::init(256), - cl::Optional, - cl::sub(HeatmapCommand)); - -} - namespace llvm { namespace bolt { diff --git a/bolt/src/ProfileReaderBase.cpp b/bolt/lib/Profile/ProfileReaderBase.cpp similarity index 93% rename from bolt/src/ProfileReaderBase.cpp rename to bolt/lib/Profile/ProfileReaderBase.cpp index ff9b1274c3a3..001ccc6fdfe7 100644 --- a/bolt/src/ProfileReaderBase.cpp +++ b/bolt/lib/Profile/ProfileReaderBase.cpp @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "ProfileReaderBase.h" +#include "bolt/Profile/ProfileReaderBase.h" namespace llvm { namespace bolt { diff --git a/bolt/src/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp similarity index 98% rename from bolt/src/YAMLProfileReader.cpp rename to bolt/lib/Profile/YAMLProfileReader.cpp index 5ee1bbef5c3e..a309eeab2df6 100644 --- a/bolt/src/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -8,12 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" -#include "Passes/MCF.h" -#include "YAMLProfileReader.h" -#include "ProfileYAMLMapping.h" -#include "Utils.h" +#include "bolt/Profile/YAMLProfileReader.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Passes/MCF.h" +#include "bolt/Profile/ProfileYAMLMapping.h" +#include "bolt/Utils/Utils.h" #include "llvm/Support/CommandLine.h" using namespace llvm; diff --git a/bolt/src/YAMLProfileWriter.cpp b/bolt/lib/Profile/YAMLProfileWriter.cpp similarity index 96% rename from bolt/src/YAMLProfileWriter.cpp rename to bolt/lib/Profile/YAMLProfileWriter.cpp index 4761db00873c..1f5ab511dad4 100644 --- a/bolt/src/YAMLProfileWriter.cpp +++ b/bolt/lib/Profile/YAMLProfileWriter.cpp @@ -9,12 +9,12 @@ // //===----------------------------------------------------------------------===// -#include "YAMLProfileWriter.h" -#include "BinaryBasicBlock.h" -#include "BinaryFunction.h" -#include "ProfileReaderBase.h" -#include "ProfileYAMLMapping.h" -#include "RewriteInstance.h" +#include "bolt/Profile/YAMLProfileWriter.h" +#include "bolt/Core/BinaryBasicBlock.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Profile/ProfileReaderBase.h" +#include "bolt/Profile/ProfileYAMLMapping.h" +#include "bolt/Rewrite/RewriteInstance.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" diff --git a/bolt/src/BinaryPassManager.cpp b/bolt/lib/Rewrite/BinaryPassManager.cpp similarity index 93% rename from bolt/src/BinaryPassManager.cpp rename to bolt/lib/Rewrite/BinaryPassManager.cpp index 5723ee9964be..573b0918d40b 100644 --- a/bolt/src/BinaryPassManager.cpp +++ b/bolt/lib/Rewrite/BinaryPassManager.cpp @@ -8,30 +8,31 @@ // //===----------------------------------------------------------------------===// -#include "BinaryPassManager.h" -#include "Passes/ADRRelaxationPass.h" -#include "Passes/Aligner.h" -#include "Passes/AllocCombiner.h" -#include "Passes/FrameOptimizer.h" -#include "Passes/IdenticalCodeFolding.h" -#include "Passes/IndirectCallPromotion.h" -#include "Passes/Inliner.h" -#include "Passes/Instrumentation.h" -#include "Passes/JTFootprintReduction.h" -#include "Passes/LongJmp.h" -#include "Passes/LoopInversionPass.h" -#include "Passes/PLTCall.h" -#include "Passes/PatchEntries.h" -#include "Passes/RegReAssign.h" -#include "Passes/ReorderData.h" -#include "Passes/ReorderFunctions.h" -#include "Passes/RetpolineInsertion.h" -#include "Passes/SplitFunctions.h" -#include "Passes/StokeInfo.h" -#include "Passes/TailDuplication.h" -#include "Passes/ThreeWayBranch.h" -#include "Passes/ValidateInternalCalls.h" -#include "Passes/VeneerElimination.h" +#include "bolt/Rewrite/BinaryPassManager.h" +#include "bolt/Passes/ADRRelaxationPass.h" +#include "bolt/Passes/Aligner.h" +#include "bolt/Passes/AllocCombiner.h" +#include "bolt/Passes/FrameOptimizer.h" +#include "bolt/Passes/IdenticalCodeFolding.h" +#include "bolt/Passes/IndirectCallPromotion.h" +#include "bolt/Passes/Inliner.h" +#include "bolt/Passes/Instrumentation.h" +#include "bolt/Passes/JTFootprintReduction.h" +#include "bolt/Passes/LongJmp.h" +#include "bolt/Passes/LoopInversionPass.h" +#include "bolt/Passes/PLTCall.h" +#include "bolt/Passes/PatchEntries.h" +#include "bolt/Passes/RegReAssign.h" +#include "bolt/Passes/ReorderData.h" +#include "bolt/Passes/ReorderFunctions.h" +#include "bolt/Passes/RetpolineInsertion.h" +#include "bolt/Passes/SplitFunctions.h" +#include "bolt/Passes/StokeInfo.h" +#include "bolt/Passes/TailDuplication.h" +#include "bolt/Passes/ThreeWayBranch.h" +#include "bolt/Passes/ValidateInternalCalls.h" +#include "bolt/Passes/VeneerElimination.h" +#include "bolt/Utils/CommandLineOpts.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" @@ -41,12 +42,6 @@ using namespace llvm; namespace opts { -extern cl::OptionCategory BoltOptCategory; -extern cl::OptionCategory BoltCategory; - -extern cl::opt Instrument; - -extern cl::opt Verbosity; extern cl::opt PrintAll; extern cl::opt PrintDynoStats; extern cl::opt DumpDotAll; @@ -276,13 +271,6 @@ StripRepRet("strip-rep-ret", cl::ZeroOrMore, cl::cat(BoltOptCategory)); -llvm::cl::opt -TimeOpts("time-opts", - cl::desc("print time spent in each optimization"), - cl::init(false), - cl::ZeroOrMore, - cl::cat(BoltOptCategory)); - static llvm::cl::opt VerifyCFG("verify-cfg", cl::desc("verify the CFG after every pass"), diff --git a/bolt/src/BoltDiff.cpp b/bolt/lib/Rewrite/BoltDiff.cpp similarity index 99% rename from bolt/src/BoltDiff.cpp rename to bolt/lib/Rewrite/BoltDiff.cpp index b80c7f2be618..85797b2727c4 100644 --- a/bolt/src/BoltDiff.cpp +++ b/bolt/lib/Rewrite/BoltDiff.cpp @@ -11,9 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "Passes/IdenticalCodeFolding.h" -#include "ProfileReaderBase.h" -#include "RewriteInstance.h" +#include "bolt/Passes/IdenticalCodeFolding.h" +#include "bolt/Profile/ProfileReaderBase.h" +#include "bolt/Rewrite/RewriteInstance.h" #include "llvm/Support/CommandLine.h" #undef DEBUG_TYPE diff --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt new file mode 100644 index 000000000000..9fd5ad8a86b2 --- /dev/null +++ b/bolt/lib/Rewrite/CMakeLists.txt @@ -0,0 +1,45 @@ +set(LLVM_LINK_COMPONENTS + BOLTCore + BOLTPasses + BOLTProfile + BOLTRuntimeLibs + BOLTUtils + DebugInfoDWARF + DWP + ExecutionEngine + MC + Object + Support + ) + +string(FIND "${LLVM_TARGETS_TO_BUILD}" "AArch64" POSITION) +if (NOT ${POSITION} EQUAL -1) + list(APPEND LLVM_LINK_COMPONENTS BOLTTargetAArch64) + set(BOLT_AArch64 On) +endif() + +string(FIND "${LLVM_TARGETS_TO_BUILD}" "X86" POSITION) +if (NOT ${POSITION} EQUAL -1) + list(APPEND LLVM_LINK_COMPONENTS BOLTTargetX86) + set(BOLT_X64 On) +endif() + +add_llvm_library(LLVMBOLTRewrite + BinaryPassManager.cpp + BoltDiff.cpp + DWARFRewriter.cpp + ExecutableFileMemoryManager.cpp + MachORewriteInstance.cpp + RewriteInstance.cpp + + LINK_LIBS + ${LLVM_PTHREAD_LIB} + ) + +if (DEFINED BOLT_AArch64) + target_compile_definitions(LLVMBOLTRewrite PRIVATE AARCH64_AVAILABLE) +endif() + +if (DEFINED BOLT_X64) + target_compile_definitions(LLVMBOLTRewrite PRIVATE X86_AVAILABLE) +endif() diff --git a/bolt/src/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp similarity index 99% rename from bolt/src/DWARFRewriter.cpp rename to bolt/lib/Rewrite/DWARFRewriter.cpp index e9c166c02849..c1a0120aa3a9 100644 --- a/bolt/src/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -8,12 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "DWARFRewriter.h" -#include "BinaryContext.h" -#include "BinaryFunction.h" -#include "DebugData.h" -#include "ParallelUtilities.h" -#include "Utils.h" +#include "bolt/Rewrite/DWARFRewriter.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Utils/Utils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DWP/DWP.h" diff --git a/bolt/src/ExecutableFileMemoryManager.cpp b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp similarity index 97% rename from bolt/src/ExecutableFileMemoryManager.cpp rename to bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp index c56cfef094ff..0343a8766569 100644 --- a/bolt/src/ExecutableFileMemoryManager.cpp +++ b/bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "ExecutableFileMemoryManager.h" -#include "RewriteInstance.h" +#include "bolt/Rewrite/ExecutableFileMemoryManager.h" +#include "bolt/Rewrite/RewriteInstance.h" #undef DEBUG_TYPE #define DEBUG_TYPE "efmm" diff --git a/bolt/src/MachORewriteInstance.cpp b/bolt/lib/Rewrite/MachORewriteInstance.cpp similarity index 92% rename from bolt/src/MachORewriteInstance.cpp rename to bolt/lib/Rewrite/MachORewriteInstance.cpp index cec1b9f25b1f..4c9357741833 100644 --- a/bolt/src/MachORewriteInstance.cpp +++ b/bolt/lib/Rewrite/MachORewriteInstance.cpp @@ -8,18 +8,19 @@ // //===----------------------------------------------------------------------===// -#include "MachORewriteInstance.h" -#include "BinaryContext.h" -#include "BinaryEmitter.h" -#include "BinaryFunction.h" -#include "BinaryPassManager.h" -#include "DataReader.h" -#include "ExecutableFileMemoryManager.h" -#include "JumpTable.h" -#include "Passes/Instrumentation.h" -#include "Passes/PatchEntries.h" -#include "RuntimeLibs/InstrumentationRuntimeLibrary.h" -#include "Utils.h" +#include "bolt/Rewrite/MachORewriteInstance.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryEmitter.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Passes/Instrumentation.h" +#include "bolt/Passes/PatchEntries.h" +#include "bolt/Profile/DataReader.h" +#include "bolt/Rewrite/BinaryPassManager.h" +#include "bolt/Rewrite/ExecutableFileMemoryManager.h" +#include "bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h" +#include "bolt/Utils/Utils.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCObjectStreamer.h" @@ -53,6 +54,34 @@ extern cl::opt Verbosity; namespace llvm { namespace bolt { +extern MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *, + const MCInstrInfo *, + const MCRegisterInfo *); +extern MCPlusBuilder *createAArch64MCPlusBuilder(const MCInstrAnalysis *, + const MCInstrInfo *, + const MCRegisterInfo *); + +namespace { + +MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch, + const MCInstrAnalysis *Analysis, + const MCInstrInfo *Info, + const MCRegisterInfo *RegInfo) { +#ifdef X86_AVAILABLE + if (Arch == Triple::x86_64) + return createX86MCPlusBuilder(Analysis, Info, RegInfo); +#endif + +#ifdef AARCH64_AVAILABLE + if (Arch == Triple::aarch64) + return createAArch64MCPlusBuilder(Analysis, Info, RegInfo); +#endif + + llvm_unreachable("architecture unsupported by MCPlusBuilder"); +} + +} // anonymous namespace + #undef DEBUG_TYPE #define DEBUG_TYPE "bolt" @@ -61,6 +90,8 @@ MachORewriteInstance::MachORewriteInstance(object::MachOObjectFile *InputFile, : InputFile(InputFile), ToolPath(ToolPath), BC(BinaryContext::createBinaryContext(InputFile, /* IsPIC */ true, DWARFContext::create(*InputFile))) { + BC->initializeTarget(std::unique_ptr(createMCPlusBuilder( + BC->TheTriple->getArch(), BC->MIA.get(), BC->MII.get(), BC->MRI.get()))); if (opts::Instrument) BC->setRuntimeLibrary(std::make_unique()); } diff --git a/bolt/src/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp similarity index 97% rename from bolt/src/RewriteInstance.cpp rename to bolt/lib/Rewrite/RewriteInstance.cpp index 43cba6884746..8ac7e5ef15da 100644 --- a/bolt/src/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -8,28 +8,29 @@ // //===----------------------------------------------------------------------===// -#include "RewriteInstance.h" -#include "BinaryContext.h" -#include "BinaryEmitter.h" -#include "BinaryFunction.h" -#include "BinaryPassManager.h" -#include "BoltAddressTranslation.h" -#include "CacheMetrics.h" -#include "DWARFRewriter.h" -#include "DataAggregator.h" -#include "DataReader.h" -#include "DebugData.h" -#include "Exceptions.h" -#include "ExecutableFileMemoryManager.h" -#include "MCPlusBuilder.h" -#include "ParallelUtilities.h" -#include "Passes/ReorderFunctions.h" -#include "Relocation.h" -#include "RuntimeLibs/HugifyRuntimeLibrary.h" -#include "RuntimeLibs/InstrumentationRuntimeLibrary.h" -#include "Utils.h" -#include "YAMLProfileReader.h" -#include "YAMLProfileWriter.h" +#include "bolt/Rewrite/RewriteInstance.h" +#include "bolt/Core/BinaryContext.h" +#include "bolt/Core/BinaryEmitter.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/DebugData.h" +#include "bolt/Core/Exceptions.h" +#include "bolt/Core/MCPlusBuilder.h" +#include "bolt/Core/ParallelUtilities.h" +#include "bolt/Core/Relocation.h" +#include "bolt/Passes/CacheMetrics.h" +#include "bolt/Passes/ReorderFunctions.h" +#include "bolt/Profile/BoltAddressTranslation.h" +#include "bolt/Profile/DataAggregator.h" +#include "bolt/Profile/DataReader.h" +#include "bolt/Profile/YAMLProfileReader.h" +#include "bolt/Profile/YAMLProfileWriter.h" +#include "bolt/Rewrite/BinaryPassManager.h" +#include "bolt/Rewrite/DWARFRewriter.h" +#include "bolt/Rewrite/ExecutableFileMemoryManager.h" +#include "bolt/RuntimeLibs/HugifyRuntimeLibrary.h" +#include "bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h" +#include "bolt/Utils/CommandLineOpts.h" +#include "bolt/Utils/Utils.h" #include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" @@ -42,6 +43,7 @@ #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/TargetRegistry.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Alignment.h" #include "llvm/Support/Casting.h" @@ -51,7 +53,6 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/raw_ostream.h" @@ -71,16 +72,8 @@ extern cl::opt X86AlignBranchWithin32BBoundaries; namespace opts { -extern bool HeatmapMode; -extern bool LinuxKernelMode; - -extern cl::OptionCategory BoltCategory; -extern cl::OptionCategory BoltDiffCategory; -extern cl::OptionCategory BoltOptCategory; -extern cl::OptionCategory BoltOutputCategory; -extern cl::OptionCategory AggregatorCategory; - extern cl::opt AlignMacroOpFusion; +extern cl::list HotTextMoveSections; extern cl::opt Hugify; extern cl::opt Instrument; extern cl::opt JumpTables; @@ -88,13 +81,6 @@ extern cl::list ReorderData; extern cl::opt ReorderFunctions; extern cl::opt TimeBuild; -cl::opt -AlignText("align-text", - cl::desc("alignment of .text section"), - cl::ZeroOrMore, - cl::Hidden, - cl::cat(BoltCategory)); - static cl::opt ForceToDataRelocations("force-data-relocations", cl::desc("force relocations to data sections to always be processed"), @@ -103,19 +89,6 @@ ForceToDataRelocations("force-data-relocations", cl::ZeroOrMore, cl::cat(BoltCategory)); -cl::opt -PrintCacheMetrics("print-cache-metrics", - cl::desc("calculate and print various metrics for instruction cache"), - cl::init(false), - cl::ZeroOrMore, - cl::cat(BoltOptCategory)); - -cl::opt -OutputFilename("o", - cl::desc(""), - cl::Optional, - cl::cat(BoltOutputCategory)); - cl::opt BoltID("bolt-id", cl::desc("add any string to tag this execution in the " @@ -150,38 +123,6 @@ FunctionNamesFile("funcs-file", cl::Hidden, cl::cat(BoltCategory)); -cl::opt -HotFunctionsAtEnd( - "hot-functions-at-end", - cl::desc( - "if reorder-functions is used, order functions putting hottest last"), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - -cl::opt HotText( - "hot-text", - cl::desc( - "Generate hot text symbols. Apply this option to a precompiled binary " - "that manually calls into hugify, such that at runtime hugify call " - "will put hot code into 2M pages. This requires relocation."), - cl::ZeroOrMore, cl::cat(BoltCategory)); - -static cl::list -HotTextMoveSections("hot-text-move-sections", - cl::desc("list of sections containing functions used for hugifying hot text. " - "BOLT makes sure these functions are not placed on the same page as " - "the hot text. (default=\'.stub,.mover\')."), - cl::value_desc("sec1,sec2,sec3,..."), - cl::CommaSeparated, - cl::ZeroOrMore, - cl::cat(BoltCategory)); - -cl::opt -HotData("hot-data", - cl::desc("hot data symbols support (relocation mode)"), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - cl::opt KeepTmp("keep-tmp", cl::desc("preserve intermediate .o file"), @@ -318,20 +259,6 @@ SkipFunctionNamesFile("skip-funcs-file", cl::Hidden, cl::cat(BoltCategory)); -cl::opt -SplitEH("split-eh", - cl::desc("split C++ exception handling code"), - cl::ZeroOrMore, - cl::Hidden, - cl::cat(BoltOptCategory)); - -cl::opt -StrictMode("strict", - cl::desc("trust the input to be from a well-formed source"), - cl::init(false), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - cl::opt TrapOldCode("trap-old-code", cl::desc("insert traps in old function bodies (relocation mode)"), @@ -343,23 +270,6 @@ static cl::opt DWPPathName("dwp", cl::Hidden, cl::ZeroOrMore, cl::init(""), cl::cat(BoltCategory)); -cl::opt -UpdateDebugSections("update-debug-sections", - cl::desc("update DWARF debug sections of the executable"), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - -cl::opt -EnableBAT("enable-bat", - cl::desc("write BOLT Address Translation tables"), - cl::init(false), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - -cl::opt RemoveSymtab("remove-symtab", cl::desc("Remove .symtab section"), - cl::init(false), cl::ZeroOrMore, - cl::cat(BoltCategory)); - static cl::opt UseGnuStack("use-gnu-stack", cl::desc("use GNU_STACK program header for new segment (workaround for " @@ -367,43 +277,6 @@ UseGnuStack("use-gnu-stack", cl::ZeroOrMore, cl::cat(BoltCategory)); -cl::opt -UseOldText("use-old-text", - cl::desc("re-use space in old .text if possible (relocation mode)"), - cl::ZeroOrMore, - cl::cat(BoltCategory)); - -// The default verbosity level (0) is pretty terse, level 1 is fairly -// verbose and usually prints some informational message for every -// function processed. Level 2 is for the noisiest of messages and -// often prints a message per basic block. -// Error messages should never be suppressed by the verbosity level. -// Only warnings and info messages should be affected. -// -// The rational behind stream usage is as follows: -// outs() for info and debugging controlled by command line flags. -// errs() for errors and warnings. -// dbgs() for output within DEBUG(). -cl::opt -Verbosity("v", - cl::desc("set verbosity level for diagnostic output"), - cl::init(0), - cl::ZeroOrMore, - cl::cat(BoltCategory), - cl::sub(*cl::AllSubCommands)); - -cl::opt -AggregateOnly("aggregate-only", - cl::desc("exit after writing aggregated data file"), - cl::Hidden, - cl::cat(AggregatorCategory)); - -cl::opt -DiffOnly("diff-only", - cl::desc("stop processing once we have enough to compare two binaries"), - cl::Hidden, - cl::cat(BoltDiffCategory)); - static cl::opt TimeRewrite("time-rewrite", cl::desc("print time spent in rewriting passes"), @@ -425,27 +298,6 @@ WriteBoltInfoSection("bolt-info", cl::Hidden, cl::cat(BoltOutputCategory)); -bool isHotTextMover(const BinaryFunction &Function) { - for (std::string &SectionName : opts::HotTextMoveSections) { - if (Function.getOriginSectionName() && - *Function.getOriginSectionName() == SectionName) - return true; - } - - return false; -} - -/// Return true if we should process all functions in the binary. -bool processAllFunctions() { - if (opts::AggregateOnly) - return false; - - if (UseOldText || StrictMode) - return true; - - return false; -} - } // namespace opts constexpr const char *RewriteInstance::SectionsToOverwrite[]; @@ -461,6 +313,13 @@ namespace bolt { extern const char *BoltRevision; +extern MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *, + const MCInstrInfo *, + const MCRegisterInfo *); +extern MCPlusBuilder *createAArch64MCPlusBuilder(const MCInstrAnalysis *, + const MCInstrInfo *, + const MCRegisterInfo *); + } // namespace bolt } // namespace llvm @@ -476,7 +335,24 @@ bool refersToReorderedSection(ErrorOr Section) { return Itr != opts::ReorderData.end(); } -} // namespace +MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch, + const MCInstrAnalysis *Analysis, + const MCInstrInfo *Info, + const MCRegisterInfo *RegInfo) { +#ifdef X86_AVAILABLE + if (Arch == Triple::x86_64) + return createX86MCPlusBuilder(Analysis, Info, RegInfo); +#endif + +#ifdef AARCH64_AVAILABLE + if (Arch == Triple::aarch64) + return createAArch64MCPlusBuilder(Analysis, Info, RegInfo); +#endif + + llvm_unreachable("architecture unsupported by MCPlusBuilder"); +} + +} // anonymous namespace RewriteInstance::RewriteInstance(ELFObjectFileBase *File, const int Argc, const char *const *Argv, StringRef ToolPath) @@ -503,6 +379,9 @@ RewriteInstance::RewriteInstance(ELFObjectFileBase *File, const int Argc, WithColor::defaultErrorHandler, WithColor::defaultWarningHandler)); + BC->initializeTarget(std::unique_ptr(createMCPlusBuilder( + BC->TheTriple->getArch(), BC->MIA.get(), BC->MII.get(), BC->MRI.get()))); + BAT = std::make_unique(*BC); if (opts::UpdateDebugSections) diff --git a/bolt/src/RuntimeLibs/CMakeLists.txt b/bolt/lib/RuntimeLibs/CMakeLists.txt similarity index 51% rename from bolt/src/RuntimeLibs/CMakeLists.txt rename to bolt/lib/RuntimeLibs/CMakeLists.txt index c657bedd175c..a489fd2f198c 100644 --- a/bolt/src/RuntimeLibs/CMakeLists.txt +++ b/bolt/lib/RuntimeLibs/CMakeLists.txt @@ -1,10 +1,16 @@ +set(LLVM_LINK_COMPONENTS + BOLTCore + BOLTPasses + BOLTUtils + BinaryFormat + MC + Object + RuntimeDyld + Support + ) + add_llvm_library(LLVMBOLTRuntimeLibs RuntimeLibrary.cpp HugifyRuntimeLibrary.cpp InstrumentationRuntimeLibrary.cpp - - DEPENDS - intrinsics_gen ) - -include_directories( ${BOLT_SOURCE_DIR}/src ) diff --git a/bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp similarity index 97% rename from bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp rename to bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp index d3b93def6996..34050e51bd83 100644 --- a/bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp +++ b/bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "HugifyRuntimeLibrary.h" -#include "BinaryFunction.h" +#include "bolt/RuntimeLibs/HugifyRuntimeLibrary.h" +#include "bolt/Core/BinaryFunction.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/Alignment.h" diff --git a/bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp similarity index 97% rename from bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp rename to bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp index 1bc276d682b1..77642b4786c9 100644 --- a/bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp +++ b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp @@ -8,9 +8,10 @@ // //===----------------------------------------------------------------------===// -#include "InstrumentationRuntimeLibrary.h" -#include "BinaryFunction.h" -#include "JumpTable.h" +#include "bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h" +#include "bolt/Core/BinaryFunction.h" +#include "bolt/Core/JumpTable.h" +#include "bolt/Utils/CommandLineOpts.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/Alignment.h" @@ -21,7 +22,10 @@ using namespace bolt; namespace opts { -extern cl::OptionCategory BoltOptCategory; +cl::opt RuntimeInstrumentationLib( + "runtime-instrumentation-lib", + cl::desc("specify file name of the runtime instrumentation library"), + cl::ZeroOrMore, cl::init("libbolt_rt_instr.a"), cl::cat(BoltOptCategory)); extern cl::opt InstrumentationFileAppendPID; extern cl::opt ConservativeInstrumentation; @@ -32,16 +36,6 @@ extern cl::opt InstrumentationNoCountersClear; extern cl::opt InstrumentationWaitForks; extern cl::opt JumpTables; -cl::opt - Instrument("instrument", - cl::desc("instrument code to generate accurate profile data"), - cl::ZeroOrMore, cl::cat(BoltOptCategory)); - -cl::opt RuntimeInstrumentationLib( - "runtime-instrumentation-lib", - cl::desc("specify file name of the runtime instrumentation library"), - cl::ZeroOrMore, cl::init("libbolt_rt_instr.a"), cl::cat(BoltOptCategory)); - } // namespace opts void InstrumentationRuntimeLibrary::adjustCommandLineOptions( diff --git a/bolt/src/RuntimeLibs/RuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp similarity index 97% rename from bolt/src/RuntimeLibs/RuntimeLibrary.cpp rename to bolt/lib/RuntimeLibs/RuntimeLibrary.cpp index 8400c51c6e4c..cf811edffcc3 100644 --- a/bolt/src/RuntimeLibs/RuntimeLibrary.cpp +++ b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp @@ -8,8 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "RuntimeLibrary.h" -#include "Utils.h" +#include "bolt/RuntimeLibs/RuntimeLibrary.h" +#include "bolt/Utils/Utils.h" #include "llvm/BinaryFormat/Magic.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/Object/Archive.h" diff --git a/bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp similarity index 99% rename from bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp rename to bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp index 88b3978fc553..ef5519b8353b 100644 --- a/bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp +++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp @@ -10,12 +10,11 @@ // //===----------------------------------------------------------------------===// -#include "MCPlus.h" -#include "MCPlusBuilder.h" #include "MCTargetDesc/AArch64AddressingModes.h" #include "MCTargetDesc/AArch64MCExpr.h" #include "MCTargetDesc/AArch64MCTargetDesc.h" #include "Utils/AArch64BaseInfo.h" +#include "bolt/Core/MCPlusBuilder.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" diff --git a/bolt/src/Target/AArch64/CMakeLists.txt b/bolt/lib/Target/AArch64/CMakeLists.txt similarity index 70% rename from bolt/src/Target/AArch64/CMakeLists.txt rename to bolt/lib/Target/AArch64/CMakeLists.txt index 124725c25a11..d9b07d73eda8 100644 --- a/bolt/src/Target/AArch64/CMakeLists.txt +++ b/bolt/lib/Target/AArch64/CMakeLists.txt @@ -1,3 +1,11 @@ +set(LLVM_LINK_COMPONENTS + BOLTCore + MC + Object + Support + ${LLVM_TARGETS_TO_BUILD} + ) + add_llvm_library(LLVMBOLTTargetAArch64 AArch64MCPlusBuilder.cpp @@ -7,4 +15,3 @@ add_llvm_library(LLVMBOLTTargetAArch64 ) include_directories(${LLVM_MAIN_SRC_DIR}/lib/Target/AArch64 ${LLVM_BINARY_DIR}/lib/Target/AArch64) -include_directories(${BOLT_SOURCE_DIR}/src) diff --git a/bolt/src/Target/CMakeLists.txt b/bolt/lib/Target/CMakeLists.txt similarity index 100% rename from bolt/src/Target/CMakeLists.txt rename to bolt/lib/Target/CMakeLists.txt diff --git a/bolt/src/Target/X86/CMakeLists.txt b/bolt/lib/Target/X86/CMakeLists.txt similarity index 68% rename from bolt/src/Target/X86/CMakeLists.txt rename to bolt/lib/Target/X86/CMakeLists.txt index 282c0c66677c..63b40183cf8d 100644 --- a/bolt/src/Target/X86/CMakeLists.txt +++ b/bolt/lib/Target/X86/CMakeLists.txt @@ -1,3 +1,11 @@ +set(LLVM_LINK_COMPONENTS + BOLTCore + MC + Object + Support + ${LLVM_TARGETS_TO_BUILD} + ) + add_llvm_library(LLVMBOLTTargetX86 X86MCPlusBuilder.cpp @@ -7,4 +15,3 @@ add_llvm_library(LLVMBOLTTargetX86 ) include_directories(${LLVM_MAIN_SRC_DIR}/lib/Target/X86 ${LLVM_BINARY_DIR}/lib/Target/X86) -include_directories(${BOLT_SOURCE_DIR}/src) diff --git a/bolt/src/Target/X86/X86MCPlusBuilder.cpp b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp similarity index 99% rename from bolt/src/Target/X86/X86MCPlusBuilder.cpp rename to bolt/lib/Target/X86/X86MCPlusBuilder.cpp index 1c7d2162c72e..ff1787ef9e64 100644 --- a/bolt/src/Target/X86/X86MCPlusBuilder.cpp +++ b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp @@ -10,9 +10,9 @@ // //===----------------------------------------------------------------------===// -#include "MCPlusBuilder.h" #include "MCTargetDesc/X86BaseInfo.h" #include "MCTargetDesc/X86MCTargetDesc.h" +#include "bolt/Core/MCPlusBuilder.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCInstBuilder.h" @@ -2874,7 +2874,7 @@ public: } bool createReturn(MCInst &Inst) const override { - Inst.setOpcode(X86::RETQ); + Inst.setOpcode(X86::RET64); return true; } diff --git a/bolt/lib/Utils/CMakeLists.txt b/bolt/lib/Utils/CMakeLists.txt new file mode 100644 index 000000000000..283a2e90f747 --- /dev/null +++ b/bolt/lib/Utils/CMakeLists.txt @@ -0,0 +1,53 @@ +# Get the current git revision for BOLT. +function(get_version ofn) + find_program(git_executable NAMES git git.exe git.cmd) + if (git_executable) + execute_process(COMMAND ${git_executable} rev-parse HEAD + WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR} + TIMEOUT 5 + RESULT_VARIABLE git_result + OUTPUT_VARIABLE git_output) + if( git_result EQUAL 0 ) + string(STRIP "${git_output}" git_ref_id) + set(BOLT_REVISION "${git_ref_id}") + endif() + endif() + + # If we can't find a revision, set it to "". + if (NOT BOLT_REVISION) + set(BOLT_REVISION "") + endif() + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} + COMMAND echo '"${BOLT_REVISION}"' > ${CMAKE_CURRENT_BINARY_DIR}/${ofn} + COMMENT "Generating bogus ${ofn}..." + ) + + set(VERSION_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE) + + # `make clean' must remove all those generated files: + set_property(DIRECTORY APPEND + PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn}) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES + GENERATED 1) +endfunction() + +# Creates a public target for generating the revision file. +function(add_public_gen_version_target target) + add_custom_target(${target} DEPENDS ${VERSION_OUTPUT}) + set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${target} PARENT_SCOPE) +endfunction() + +get_version(BoltRevision.inc) +add_public_gen_version_target(GenBoltRevision) + +add_llvm_library(LLVMBOLTUtils + CommandLineOpts.cpp + Utils.cpp + + LINK_LIBS + ${LLVM_PTHREAD_LIB} + + LINK_COMPONENTS + Support + ) diff --git a/bolt/lib/Utils/CommandLineOpts.cpp b/bolt/lib/Utils/CommandLineOpts.cpp new file mode 100644 index 000000000000..30e98c119144 --- /dev/null +++ b/bolt/lib/Utils/CommandLineOpts.cpp @@ -0,0 +1,232 @@ +//===--- CommandLineOpts.cpp - BOLT CLI options ---------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// BOLT CLI options +// +//===----------------------------------------------------------------------===// + +#include "bolt/Utils/CommandLineOpts.h" + +using namespace llvm; + +namespace llvm { +namespace bolt { +const char *BoltRevision = +#include "BoltRevision.inc" +; +} +} + +namespace opts { + +bool HeatmapMode = false; +bool LinuxKernelMode = false; + +cl::OptionCategory BoltCategory("BOLT generic options"); +cl::OptionCategory BoltDiffCategory("BOLTDIFF generic options"); +cl::OptionCategory BoltOptCategory("BOLT optimization options"); +cl::OptionCategory BoltRelocCategory("BOLT options in relocation mode"); +cl::OptionCategory BoltOutputCategory("Output options"); +cl::OptionCategory AggregatorCategory("Data aggregation options"); +cl::OptionCategory BoltInstrCategory("BOLT instrumentation options"); + +cl::SubCommand HeatmapCommand("heatmap", "generate heatmap"); + +cl::opt +AlignText("align-text", + cl::desc("alignment of .text section"), + cl::ZeroOrMore, + cl::Hidden, + cl::cat(BoltCategory)); + +cl::opt +AggregateOnly("aggregate-only", + cl::desc("exit after writing aggregated data file"), + cl::Hidden, + cl::cat(AggregatorCategory)); + +cl::opt +BucketsPerLine("line-size", + cl::desc("number of entries per line (default 256)"), + cl::init(256), + cl::Optional, + cl::sub(HeatmapCommand)); + +cl::opt +DiffOnly("diff-only", + cl::desc("stop processing once we have enough to compare two binaries"), + cl::Hidden, + cl::cat(BoltDiffCategory)); + +cl::opt +EnableBAT("enable-bat", + cl::desc("write BOLT Address Translation tables"), + cl::init(false), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt RemoveSymtab("remove-symtab", cl::desc("Remove .symtab section"), + cl::init(false), cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt +ExecutionCountThreshold("execution-count-threshold", + cl::desc("perform profiling accuracy-sensitive optimizations only if " + "function execution count >= the threshold (default: 0)"), + cl::init(0), + cl::ZeroOrMore, + cl::Hidden, + cl::cat(BoltOptCategory)); + +cl::opt +HeatmapBlock("block-size", + cl::desc("size of a heat map block in bytes (default 64)"), + cl::init(64), + cl::sub(HeatmapCommand)); + +cl::opt +HeatmapFile("o", + cl::init("-"), + cl::desc("heatmap output file (default stdout)"), + cl::Optional, + cl::sub(HeatmapCommand)); + +cl::opt +HeatmapMaxAddress("max-address", + cl::init(0xffffffff), + cl::desc("maximum address considered valid for heatmap (default 4GB)"), + cl::Optional, + cl::sub(HeatmapCommand)); + +cl::opt +HeatmapMinAddress("min-address", + cl::init(0x0), + cl::desc("minimum address considered valid for heatmap (default 0)"), + cl::Optional, + cl::sub(HeatmapCommand)); + +cl::opt +HotData("hot-data", + cl::desc("hot data symbols support (relocation mode)"), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt +HotFunctionsAtEnd( + "hot-functions-at-end", + cl::desc( + "if reorder-functions is used, order functions putting hottest last"), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt HotText( + "hot-text", + cl::desc( + "Generate hot text symbols. Apply this option to a precompiled binary " + "that manually calls into hugify, such that at runtime hugify call " + "will put hot code into 2M pages. This requires relocation."), + cl::ZeroOrMore, cl::cat(BoltCategory)); + +cl::opt +InputFilename( + cl::Positional, + cl::desc(""), + cl::Required, + cl::cat(BoltCategory), + cl::sub(*cl::AllSubCommands)); + +cl::opt + Instrument("instrument", + cl::desc("instrument code to generate accurate profile data"), + cl::ZeroOrMore, cl::cat(BoltOptCategory)); + +cl::opt +OutputFilename("o", + cl::desc(""), + cl::Optional, + cl::cat(BoltOutputCategory)); + +cl::opt +PerfData("perfdata", + cl::desc(""), + cl::Optional, + cl::cat(AggregatorCategory), + cl::sub(*cl::AllSubCommands)); + +static cl::alias +PerfDataA("p", + cl::desc("alias for -perfdata"), + cl::aliasopt(PerfData), + cl::cat(AggregatorCategory)); + +cl::opt +PrintCacheMetrics("print-cache-metrics", + cl::desc("calculate and print various metrics for instruction cache"), + cl::init(false), + cl::ZeroOrMore, + cl::cat(BoltOptCategory)); + +cl::opt + PrintSections("print-sections", + cl::desc("print all registered sections"), + cl::ZeroOrMore, + cl::Hidden, + cl::cat(BoltCategory)); + +cl::opt +SplitEH("split-eh", + cl::desc("split C++ exception handling code"), + cl::ZeroOrMore, + cl::Hidden, + cl::cat(BoltOptCategory)); + +cl::opt +StrictMode("strict", + cl::desc("trust the input to be from a well-formed source"), + cl::init(false), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +llvm::cl::opt +TimeOpts("time-opts", + cl::desc("print time spent in each optimization"), + cl::init(false), + cl::ZeroOrMore, + cl::cat(BoltOptCategory)); + +cl::opt +UseOldText("use-old-text", + cl::desc("re-use space in old .text if possible (relocation mode)"), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt +UpdateDebugSections("update-debug-sections", + cl::desc("update DWARF debug sections of the executable"), + cl::ZeroOrMore, + cl::cat(BoltCategory)); + +cl::opt +Verbosity("v", + cl::desc("set verbosity level for diagnostic output"), + cl::init(0), + cl::ZeroOrMore, + cl::cat(BoltCategory), + cl::sub(*cl::AllSubCommands)); + +bool processAllFunctions() { + if (opts::AggregateOnly) + return false; + + if (UseOldText || StrictMode) + return true; + + return false; +} + +} // namespace opts diff --git a/bolt/src/Utils.cpp b/bolt/lib/Utils/Utils.cpp similarity index 98% rename from bolt/src/Utils.cpp rename to bolt/lib/Utils/Utils.cpp index 75693f2e8377..9abcfc46b24f 100644 --- a/bolt/src/Utils.cpp +++ b/bolt/lib/Utils/Utils.cpp @@ -10,9 +10,10 @@ // //===----------------------------------------------------------------------===// -#include "Utils.h" +#include "bolt/Utils/Utils.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/MC/MCDwarf.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" diff --git a/bolt/src/CMakeLists.txt b/bolt/src/CMakeLists.txt deleted file mode 100644 index dcd58f0521b6..000000000000 --- a/bolt/src/CMakeLists.txt +++ /dev/null @@ -1,124 +0,0 @@ -add_subdirectory(merge-fdata) -add_subdirectory(Passes) -add_subdirectory(RuntimeLibs) -add_subdirectory(Target) - -# Get the current git revision for BOLT. -function(get_version ofn) - find_program(git_executable NAMES git git.exe git.cmd) - if (git_executable) - execute_process(COMMAND ${git_executable} rev-parse HEAD - WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR} - TIMEOUT 5 - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_output) - if( git_result EQUAL 0 ) - string(STRIP "${git_output}" git_ref_id) - set(BOLT_REVISION "${git_ref_id}") - endif() - endif() - - # If we can't find a revision, set it to "". - if (NOT BOLT_REVISION) - set(BOLT_REVISION "") - endif() - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} - COMMAND echo '"${BOLT_REVISION}"' > ${CMAKE_CURRENT_BINARY_DIR}/${ofn} - COMMENT "Generating bogus ${ofn}..." - ) - - set(VERSION_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn} PARENT_SCOPE) - - # `make clean' must remove all those generated files: - set_property(DIRECTORY APPEND - PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${ofn}) - set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn} PROPERTIES - GENERATED 1) -endfunction() - -# Creates a public target for generating the revision file. -function(add_public_gen_version_target target) - add_custom_target(${target} DEPENDS ${VERSION_OUTPUT}) - set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${target} PARENT_SCOPE) -endfunction() - -get_version(BoltRevision.inc) -add_public_gen_version_target(GenBoltRevision) - -set(LLVM_LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - BOLTPasses - BOLTRuntimeLibs - CodeGen - Core - DebugInfoDWARF - DWP - MC - MCDisassembler - MCParser - Object - Orcjit - Support - ) - -string(FIND "${LLVM_TARGETS_TO_BUILD}" "AArch64" POSITION) -if (NOT ${POSITION} EQUAL -1) - list(APPEND LLVM_LINK_COMPONENTS BOLTTargetAArch64) - set(BOLT_AArch64 On) -endif() - -string(FIND "${LLVM_TARGETS_TO_BUILD}" "X86" POSITION) -if (NOT ${POSITION} EQUAL -1) - list(APPEND LLVM_LINK_COMPONENTS BOLTTargetX86) - set(BOLT_X64 On) -endif() - -add_llvm_tool(llvm-bolt - llvm-bolt.cpp - BinaryBasicBlock.cpp - BinaryContext.cpp - BinaryData.cpp - BinaryEmitter.cpp - BinaryFunction.cpp - BinaryFunctionProfile.cpp - BinaryPassManager.cpp - BinarySection.cpp - BoltAddressTranslation.cpp - BoltDiff.cpp - CacheMetrics.cpp - DataAggregator.cpp - DataReader.cpp - DebugData.cpp - DWARFRewriter.cpp - DynoStats.cpp - Exceptions.cpp - ExecutableFileMemoryManager.cpp - Heatmap.cpp - JumpTable.cpp - MachORewriteInstance.cpp - MCPlusBuilder.cpp - ParallelUtilities.cpp - ProfileReaderBase.cpp - Relocation.cpp - RewriteInstance.cpp - Utils.cpp - YAMLProfileReader.cpp - YAMLProfileWriter.cpp - - DEPENDS - intrinsics_gen - bolt_rt - ) - -if (DEFINED BOLT_AArch64) - target_compile_definitions(llvm-bolt PRIVATE AARCH64_AVAILABLE) -endif() - -if (DEFINED BOLT_X64) - target_compile_definitions(llvm-bolt PRIVATE X86_AVAILABLE) -endif() - -add_llvm_tool_symlink(perf2bolt llvm-bolt) -add_llvm_tool_symlink(llvm-boltdiff llvm-bolt) -add_llvm_tool_symlink(llvm-bolt-heatmap llvm-bolt) diff --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt new file mode 100644 index 000000000000..2153a9b720b0 --- /dev/null +++ b/bolt/tools/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(driver) +add_subdirectory(merge-fdata) diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt new file mode 100644 index 000000000000..8ea0e5c2ee84 --- /dev/null +++ b/bolt/tools/driver/CMakeLists.txt @@ -0,0 +1,22 @@ +set(LLVM_LINK_COMPONENTS + ${LLVM_TARGETS_TO_BUILD} + BOLTProfile + BOLTRewrite + BOLTUtils + MC + Object + Support + ) + +add_llvm_tool(llvm-bolt + llvm-bolt.cpp + + DEPENDS + bolt_rt + ) + +add_llvm_tool_symlink(perf2bolt llvm-bolt) +add_llvm_tool_symlink(llvm-boltdiff llvm-bolt) +add_llvm_tool_symlink(llvm-bolt-heatmap llvm-bolt) + +include_directories( ${BOLT_SOURCE_DIR}/lib ) diff --git a/bolt/src/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp similarity index 87% rename from bolt/src/llvm-bolt.cpp rename to bolt/tools/driver/llvm-bolt.cpp index 16b30026fb54..6bafc2333c55 100644 --- a/bolt/src/llvm-bolt.cpp +++ b/bolt/tools/driver/llvm-bolt.cpp @@ -12,9 +12,11 @@ // //===----------------------------------------------------------------------===// -#include "DataAggregator.h" -#include "MachORewriteInstance.h" -#include "RewriteInstance.h" +#include "bolt/Profile/DataAggregator.h" +#include "bolt/Rewrite/MachORewriteInstance.h" +#include "bolt/Rewrite/RewriteInstance.h" +#include "bolt/Utils/CommandLineOpts.h" +#include "llvm/MC/TargetRegistry.h" #include "llvm/Object/Binary.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" @@ -23,7 +25,6 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" -#include "llvm/Support/TargetRegistry.h" #undef DEBUG_TYPE #define DEBUG_TYPE "bolt" @@ -34,17 +35,6 @@ using namespace bolt; namespace opts { -bool HeatmapMode = false; -bool LinuxKernelMode = false; - -cl::OptionCategory BoltCategory("BOLT generic options"); -cl::OptionCategory BoltDiffCategory("BOLTDIFF generic options"); -cl::OptionCategory BoltOptCategory("BOLT optimization options"); -cl::OptionCategory BoltRelocCategory("BOLT options in relocation mode"); -cl::OptionCategory BoltOutputCategory("Output options"); -cl::OptionCategory AggregatorCategory("Data aggregation options"); -cl::OptionCategory BoltInstrCategory("BOLT instrumentation options"); - static cl::OptionCategory *BoltCategories[] = {&BoltCategory, &BoltOptCategory, &BoltRelocCategory, @@ -56,12 +46,6 @@ static cl::OptionCategory *BoltDiffCategories[] = {&BoltDiffCategory}; static cl::OptionCategory *Perf2BoltCategories[] = {&AggregatorCategory, &BoltOutputCategory}; -cl::SubCommand HeatmapCommand("heatmap", "generate heatmap"); - -extern cl::opt OutputFilename; -extern cl::opt AggregateOnly; -extern cl::opt DiffOnly; - static cl::opt InputDataFilename("data", cl::desc(""), @@ -80,14 +64,6 @@ InputDataFilename2("data2", cl::Optional, cl::cat(BoltCategory)); -static cl::opt -InputFilename( - cl::Positional, - cl::desc(""), - cl::Required, - cl::cat(BoltCategory), - cl::sub(*cl::AllSubCommands)); - static cl::opt InputFilename2( cl::Positional, @@ -95,26 +71,6 @@ InputFilename2( cl::Optional, cl::cat(BoltDiffCategory)); -static cl::opt -PerfData("perfdata", - cl::desc(""), - cl::Optional, - cl::cat(AggregatorCategory), - cl::sub(*cl::AllSubCommands)); - -static cl::alias -PerfDataA("p", - cl::desc("alias for -perfdata"), - cl::aliasopt(PerfData), - cl::cat(AggregatorCategory)); - -cl::opt - PrintSections("print-sections", - cl::desc("print all registered sections"), - cl::ZeroOrMore, - cl::Hidden, - cl::cat(BoltCategory)); - } // namespace opts static StringRef ToolName; @@ -132,14 +88,6 @@ static void report_error(StringRef Message, Error E) { exit(1); } -namespace llvm { -namespace bolt { -const char *BoltRevision = -#include "BoltRevision.inc" -; -} -} - static void printBoltRevision(llvm::raw_ostream &OS) { OS << "BOLT revision " << BoltRevision << "\n"; } diff --git a/bolt/src/merge-fdata/CMakeLists.txt b/bolt/tools/merge-fdata/CMakeLists.txt similarity index 100% rename from bolt/src/merge-fdata/CMakeLists.txt rename to bolt/tools/merge-fdata/CMakeLists.txt diff --git a/bolt/src/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp similarity index 99% rename from bolt/src/merge-fdata/merge-fdata.cpp rename to bolt/tools/merge-fdata/merge-fdata.cpp index f38dbe500704..0f4aa1fc4da8 100644 --- a/bolt/src/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -10,11 +10,11 @@ // //===----------------------------------------------------------------------===// -#include "../ProfileYAMLMapping.h" +#include "bolt/Profile/ProfileYAMLMapping.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include