#include "bolt/Passes/Inliner.h"
#include "bolt/Core/MCPlus.h"
#include "llvm/Support/CommandLine.h"
#define DEBUG_TYPE …
usingnamespacellvm;
namespace opts {
extern cl::OptionCategory BoltOptCategory;
static cl::opt<bool>
AdjustProfile("inline-ap",
cl::desc("adjust function profile after inlining"),
cl::cat(BoltOptCategory));
static cl::list<std::string>
ForceInlineFunctions("force-inline",
cl::CommaSeparated,
cl::desc("list of functions to always consider for inlining"),
cl::value_desc("func1,func2,func3,..."),
cl::Hidden,
cl::cat(BoltOptCategory));
static cl::opt<bool> InlineAll("inline-all", cl::desc("inline all functions"),
cl::cat(BoltOptCategory));
static cl::opt<bool> InlineIgnoreLeafCFI(
"inline-ignore-leaf-cfi",
cl::desc("inline leaf functions with CFI programs (can break unwinding)"),
cl::init(true), cl::ReallyHidden, cl::cat(BoltOptCategory));
static cl::opt<bool> InlineIgnoreCFI(
"inline-ignore-cfi",
cl::desc(
"inline functions with CFI programs (can break exception handling)"),
cl::ReallyHidden, cl::cat(BoltOptCategory));
static cl::opt<unsigned>
InlineLimit("inline-limit",
cl::desc("maximum number of call sites to inline"), cl::init(0),
cl::Hidden, cl::cat(BoltOptCategory));
static cl::opt<unsigned>
InlineMaxIters("inline-max-iters",
cl::desc("maximum number of inline iterations"), cl::init(3),
cl::Hidden, cl::cat(BoltOptCategory));
static cl::opt<bool> InlineSmallFunctions(
"inline-small-functions",
cl::desc("inline functions if increase in size is less than defined by "
"-inline-small-functions-bytes"),
cl::cat(BoltOptCategory));
static cl::opt<unsigned> InlineSmallFunctionsBytes(
"inline-small-functions-bytes",
cl::desc("max number of bytes for the function to be considered small for "
"inlining purposes"),
cl::init(4), cl::Hidden, cl::cat(BoltOptCategory));
static cl::opt<bool> NoInline(
"no-inline",
cl::desc("disable all inlining (overrides other inlining options)"),
cl::cat(BoltOptCategory));
bool inliningEnabled() { … }
bool mustConsider(const llvm::bolt::BinaryFunction &Function) { … }
void syncOptions() { … }
}
namespace llvm {
namespace bolt {
uint64_t Inliner::SizeOfCallInst;
uint64_t Inliner::SizeOfTailCallInst;
uint64_t Inliner::getSizeOfCallInst(const BinaryContext &BC) { … }
uint64_t Inliner::getSizeOfTailCallInst(const BinaryContext &BC) { … }
InliningInfo getInliningInfo(const BinaryFunction &BF) { … }
void Inliner::findInliningCandidates(BinaryContext &BC) { … }
std::pair<BinaryBasicBlock *, BinaryBasicBlock::iterator>
Inliner::inlineCall(BinaryBasicBlock &CallerBB,
BinaryBasicBlock::iterator CallInst,
const BinaryFunction &Callee) { … }
bool Inliner::inlineCallsInFunction(BinaryFunction &Function) { … }
Error Inliner::runOnFunctions(BinaryContext &BC) { … }
}
}