#include "CSPreInliner.h"
#include "ProfiledBinary.h"
#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
#include "llvm/Transforms/IPO/SampleProfile.h"
#include <cstdint>
#include <queue>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespacesampleprof;
STATISTIC(PreInlNumCSInlined,
"Number of functions inlined with context sensitive profile");
STATISTIC(PreInlNumCSNotInlined,
"Number of functions not inlined with context sensitive profile");
STATISTIC(PreInlNumCSInlinedHitMinLimit,
"Number of functions with FDO inline stopped due to min size limit");
STATISTIC(PreInlNumCSInlinedHitMaxLimit,
"Number of functions with FDO inline stopped due to max size limit");
STATISTIC(
PreInlNumCSInlinedHitGrowthLimit,
"Number of functions with FDO inline stopped due to growth size limit");
namespace llvm {
cl::opt<bool> EnableCSPreInliner(
"csspgo-preinliner", cl::Hidden, cl::init(true),
cl::desc("Run a global pre-inliner to merge context profile based on "
"estimated global top-down inline decisions"));
cl::opt<bool> UseContextCostForPreInliner(
"use-context-cost-for-preinliner", cl::Hidden, cl::init(true),
cl::desc("Use context-sensitive byte size cost for preinliner decisions"));
}
static cl::opt<bool> SamplePreInlineReplay(
"csspgo-replay-preinline", cl::Hidden, cl::init(false),
cl::desc(
"Replay previous inlining and adjust context profile accordingly"));
static cl::opt<int> CSPreinlMultiplierForPrevInl(
"csspgo-preinliner-multiplier-for-previous-inlining", cl::Hidden,
cl::init(100),
cl::desc(
"Multiplier to bump up callsite threshold for previous inlining."));
CSPreInliner::CSPreInliner(SampleContextTracker &Tracker,
ProfiledBinary &Binary, ProfileSummary *Summary)
: … { … }
std::vector<FunctionId> CSPreInliner::buildTopDownOrder() { … }
bool CSPreInliner::getInlineCandidates(ProfiledCandidateQueue &CQueue,
const FunctionSamples *CallerSamples) { … }
uint32_t CSPreInliner::getFuncSize(const ContextTrieNode *ContextNode) { … }
bool CSPreInliner::shouldInline(ProfiledInlineCandidate &Candidate) { … }
void CSPreInliner::processFunction(const FunctionId Name) { … }
void CSPreInliner::run() { … }