mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
Summary: Add support to read profiles collected without LBR. This involves adapting our data aggregator perf2bolt and adding support in llvm-bolt itself to read this data. This patch also introduces different options to convert basic block execution count to edge count, so BOLT can operate with its regular algorithms to perform basic block layout. The most successful approach is the default one. (cherry picked from FBD5664735)
69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
//===--- BinaryPassManager.h - Binary-level analysis/optimization passes --===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// A very simple binary-level analysis/optimization passes system.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_PASS_MANAGER_H
|
|
#define LLVM_TOOLS_LLVM_BOLT_BINARY_FUNCTION_PASS_MANAGER_H
|
|
|
|
#include "BinaryFunction.h"
|
|
#include "Passes/BinaryPasses.h"
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace llvm {
|
|
namespace bolt {
|
|
|
|
/// Simple class for managing analyses and optimizations on BinaryFunctions.
|
|
class BinaryFunctionPassManager {
|
|
private:
|
|
BinaryContext &BC;
|
|
std::map<uint64_t, BinaryFunction> &BFs;
|
|
std::set<uint64_t> &LargeFunctions;
|
|
std::vector<std::pair<const bool,
|
|
std::unique_ptr<BinaryFunctionPass>>> Passes;
|
|
|
|
public:
|
|
static const char TimerGroupName[];
|
|
|
|
BinaryFunctionPassManager(BinaryContext &BC,
|
|
std::map<uint64_t, BinaryFunction> &BFs,
|
|
std::set<uint64_t> &LargeFunctions)
|
|
: BC(BC), BFs(BFs), LargeFunctions(LargeFunctions) {}
|
|
|
|
/// Adds a pass to this manager based on the value of its corresponding
|
|
/// command-line option.
|
|
void registerPass(std::unique_ptr<BinaryFunctionPass> Pass,
|
|
const bool Run) {
|
|
Passes.emplace_back(Run, std::move(Pass));
|
|
}
|
|
|
|
/// Adds an unconditionally run pass to this manager.
|
|
void registerPass(std::unique_ptr<BinaryFunctionPass> Pass) {
|
|
Passes.emplace_back(true, std::move(Pass));
|
|
}
|
|
|
|
/// Run all registered passes in the order they were added.
|
|
void runPasses();
|
|
|
|
/// Runs all enabled implemented passes on all functions.
|
|
static void runAllPasses(BinaryContext &BC,
|
|
std::map<uint64_t, BinaryFunction> &Functions,
|
|
std::set<uint64_t> &LargeFunctions);
|
|
|
|
};
|
|
|
|
} // namespace bolt
|
|
} // namespace llvm
|
|
|
|
#endif
|