46 #define DEBUG_TYPE "synthetic-counts-propagation" 52 cl::desc(
"Initial value of synthetic entry count."));
57 cl::desc(
"Initial synthetic entry count for inline functions."));
62 cl::desc(
"Initial synthetic entry count for cold functions."));
67 auto MayHaveIndirectCalls = [](
Function &
F) {
68 for (
auto *U :
F.users()) {
69 if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
77 if (
F.isDeclaration())
79 if (
F.hasFnAttribute(Attribute::AlwaysInline) ||
80 F.hasFnAttribute(Attribute::InlineHint)) {
84 }
else if (
F.hasLocalLinkage() && !MayHaveIndirectCalls(
F)) {
89 F.hasFnAttribute(Attribute::NoInline)) {
93 SetCount(&
F, InitialCount);
111 assert(isa<Instruction>(Edge.first));
112 CallSite CS(cast<Instruction>(Edge.first));
117 Scaled64 BBFreq(
BFI.getBlockFreq(CSBB).getFrequency(), 0);
125 &CG, GetCallSiteRelFreq,
135 for (
auto Entry : Counts)
136 Entry.first->setEntryCount(
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Compute iterated dominance frontiers using a linear time algorithm.
A Module instance is used to store all the information related to an LLVM module. ...
An efficient, type-erasing, non-owning reference to a callable.
static cl::opt< int > InitialSyntheticCount("initial-synthetic-count", cl::Hidden, cl::init(10), cl::ZeroOrMore, cl::desc("Initial value of synthetic entry count."))
Initial synthetic count assigned to functions.
A node in the call graph for a module.
static void propagate(const CallGraphType &CG, GetRelBBFreqTy GetRelBBFreq, GetCountTy GetCount, AddCountTy AddCount)
Propgate synthetic entry counts on a callgraph CG.
static cl::opt< int > ColdSyntheticCount("cold-synthetic-count", cl::Hidden, cl::init(5), cl::ZeroOrMore, cl::desc("Initial synthetic entry count for cold functions."))
Initial synthetic count assigned to cold functions.
InstrTy * getInstruction() const
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Function::ProfileCount ProfileCount
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Class to represent profile counts.
Function * getFunction() const
Returns the function that this call graph node represents.
Analysis pass which computes BlockFrequencyInfo.
Module.h This file contains the declarations for the Module class.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
The basic data container for the call graph of a Module of IR.
FunTy * getCaller() const
Return the caller function for this call site.
std::pair< WeakTrackingVH, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called...
static void initializeCounts(Module &M, function_ref< void(Function *, uint64_t)> SetCount)
static cl::opt< int > InlineSyntheticCount("inline-synthetic-count", cl::Hidden, cl::init(15), cl::ZeroOrMore, cl::desc("Initial synthetic entry count for inline functions."))
Initial synthetic count assigned to inline functions.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
const BasicBlock * getParent() const
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...