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)
This commit is contained in:
parent
46bc197d72
commit
a34c753fe7
|
@ -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)
|
||||
|
|
|
@ -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 <functional>
|
||||
#include <map>
|
||||
|
@ -221,6 +221,11 @@ public:
|
|||
/// overwritten, but it is okay to re-generate debug info for them.
|
||||
std::set<const DWARFUnit *> ProcessedCUs;
|
||||
|
||||
// Setup MCPlus target builder
|
||||
void initializeTarget(std::unique_ptr<MCPlusBuilder> TargetBuilder) {
|
||||
MIB = std::move(TargetBuilder);
|
||||
}
|
||||
|
||||
/// Given DWOId returns CU if it exists in DWOCUs.
|
||||
Optional<DWARFUnit *> getDWOCU(uint64_t DWOId);
|
||||
|
|
@ -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"
|
|
@ -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"
|
|
@ -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 <map>
|
||||
#include <vector>
|
||||
|
|
@ -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"
|
|
@ -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;
|
|
@ -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
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 <unordered_map>
|
||||
#include <functional>
|
||||
#include "bolt/Passes/CallGraph.h"
|
||||
#include <deque>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace llvm {
|
||||
namespace bolt {
|
|
@ -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 <atomic>
|
||||
#include <map>
|
|
@ -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 <queue>
|
||||
|
|
@ -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 {
|
|
@ -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"
|
||||
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 <string>
|
||||
#include <vector>
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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:
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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"
|
|
@ -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"
|
||||
|
|
@ -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 {
|
|
@ -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 <unordered_map>
|
||||
#include "bolt/Core/BinaryFunction.h"
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -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 <unordered_map>
|
||||
|
||||
namespace llvm {
|
|
@ -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 {
|
|
@ -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 <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -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 {
|
|
@ -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 <atomic>
|
||||
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 <fstream>
|
||||
#include "BinaryPasses.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace bolt {
|
|
@ -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:
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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"
|
|
@ -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"
|
|
@ -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 <vector>
|
|
@ -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 <unordered_set>
|
||||
|
||||
namespace llvm {
|
|
@ -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 <memory>
|
||||
#include <vector>
|
||||
|
|
@ -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 <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
|
@ -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 <memory>
|
||||
|
|
@ -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"
|
|
@ -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 {
|
|
@ -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 {
|
82
bolt/include/bolt/Utils/CommandLineOpts.h
Normal file
82
bolt/include/bolt/Utils/CommandLineOpts.h
Normal file
|
@ -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<unsigned> AlignText;
|
||||
extern llvm::cl::opt<bool> AggregateOnly;
|
||||
extern llvm::cl::opt<unsigned> BucketsPerLine;
|
||||
extern llvm::cl::opt<bool> DiffOnly;
|
||||
extern llvm::cl::opt<bool> EnableBAT;
|
||||
extern llvm::cl::opt<bool> RemoveSymtab;
|
||||
extern llvm::cl::opt<unsigned> ExecutionCountThreshold;
|
||||
extern llvm::cl::opt<unsigned> HeatmapBlock;
|
||||
extern llvm::cl::opt<std::string> HeatmapFile;
|
||||
extern llvm::cl::opt<unsigned long long> HeatmapMaxAddress;
|
||||
extern llvm::cl::opt<unsigned long long> HeatmapMinAddress;
|
||||
extern llvm::cl::opt<bool> HotData;
|
||||
extern llvm::cl::opt<bool> HotFunctionsAtEnd;
|
||||
extern llvm::cl::opt<bool> HotText;
|
||||
extern llvm::cl::opt<std::string> InputFilename;
|
||||
extern llvm::cl::opt<bool> Instrument;
|
||||
extern llvm::cl::opt<std::string> OutputFilename;
|
||||
extern llvm::cl::opt<std::string> PerfData;
|
||||
extern llvm::cl::opt<bool> PrintCacheMetrics;
|
||||
extern llvm::cl::opt<bool> PrintSections;
|
||||
extern llvm::cl::opt<bool> SplitEH;
|
||||
extern llvm::cl::opt<bool> StrictMode;
|
||||
extern llvm::cl::opt<bool> TimeOpts;
|
||||
extern llvm::cl::opt<bool> UseOldText;
|
||||
extern llvm::cl::opt<bool> 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<unsigned> Verbosity;
|
||||
|
||||
/// Return true if we should process all functions in the binary.
|
||||
bool processAllFunctions();
|
||||
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
namespace bolt {
|
||||
extern const char *BoltRevision;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
7
bolt/lib/CMakeLists.txt
Normal file
7
bolt/lib/CMakeLists.txt
Normal file
|
@ -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)
|
|
@ -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"
|
|
@ -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<bool> AggregateOnly;
|
||||
extern cl::opt<bool> HotText;
|
||||
extern cl::opt<bool> HotData;
|
||||
extern cl::opt<bool> StrictMode;
|
||||
extern cl::opt<bool> UseOldText;
|
||||
extern cl::opt<unsigned> Verbosity;
|
||||
extern cl::opt<unsigned> ExecutionCountThreshold;
|
||||
|
||||
extern bool processAllFunctions();
|
||||
|
||||
cl::opt<bool>
|
||||
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<BinaryContext>
|
||||
|
@ -256,14 +217,6 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<MCPlusBuilder> 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<MCInstPrinter> 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;
|
|
@ -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"
|
||||
|
|
@ -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<unsigned> AlignText;
|
||||
extern cl::opt<bool> HotText;
|
||||
extern cl::opt<JumpTableSupportLevel> JumpTables;
|
||||
extern cl::opt<bool> PreserveBlocksAlignment;
|
||||
extern cl::opt<bool> PrintCacheMetrics;
|
||||
extern cl::opt<bool> UpdateDebugSections;
|
||||
extern cl::opt<unsigned> Verbosity;
|
||||
|
||||
cl::opt<bool>
|
||||
AlignBlocks("align-blocks",
|
|
@ -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"
|
|
@ -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<IndirectCallPromotionType> IndirectCallPromotion;
|
||||
extern cl::opt<JumpTableSupportLevel> JumpTables;
|
||||
|
||||
static cl::opt<MCFCostFunction>
|
||||
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<IndirectCallPromotionType>
|
||||
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<JumpTableSupportLevel> JumpTables;
|
||||
|
||||
static cl::opt<bool>
|
||||
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();
|
|
@ -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"
|
||||
|
27
bolt/lib/Core/CMakeLists.txt
Normal file
27
bolt/lib/Core/CMakeLists.txt
Normal file
|
@ -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}
|
||||
)
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
||||
|
|
@ -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"
|
|
@ -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 <mutex>
|
|
@ -8,7 +8,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "Relocation.h"
|
||||
#include "bolt/Core/Relocation.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ADRRelaxationPass.h"
|
||||
#include "ParallelUtilities.h"
|
||||
#include "bolt/Passes/ADRRelaxationPass.h"
|
||||
#include "bolt/Core/ParallelUtilities.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
|
@ -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"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user