9#ifndef LLVM_ANALYSIS_CTXPROFANALYSIS_H
10#define LLVM_ANALYSIS_CTXPROFANALYSIS_H
28 std::map<GlobalValue::GUID, SmallVector<uint64_t, 1>>;
37 const std::string Name;
39 FunctionInfo(
StringRef Name) : Name(Name) {}
41 std::optional<PGOCtxProfContext::CallTargetMapTy> Profiles;
44 std::map<GlobalValue::GUID, FunctionInfo> FuncInfo;
51 PGOContextualProfile() =
default;
59 operator bool()
const {
return Profiles.has_value(); }
66 return getDefinedFunctionGUID(
F) != 0;
70 auto It = FuncInfo.
find(GUID);
71 if (It == FuncInfo.end())
73 return It->second.Name;
78 return FuncInfo.find(getDefinedFunctionGUID(
F))->second.NextCounterIndex;
83 return FuncInfo.find(getDefinedFunctionGUID(
F))->second.NextCallsiteIndex;
88 return FuncInfo.find(getDefinedFunctionGUID(
F))->second.NextCounterIndex++;
93 return FuncInfo.find(getDefinedFunctionGUID(
F))->second.NextCallsiteIndex++;
109 return !PAC.preservedWhenStateless();
114 const std::optional<StringRef> Profile;
118 explicit CtxProfAnalysis(std::optional<StringRef> Profile = std::nullopt);
137 SetVector<std::pair<CallBase *, Function *>> &Candidates);
This header defines various interfaces for pass management in LLVM.
Reader for contextual iFDO profile, which comes in bitstream format.
ModuleAnalysisManager MAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
Assign a GUID to functions as metadata.
static uint64_t getGUID(const Function &F)
static const char * GUIDMetadataName
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Assign a GUID if one is not already assign, as a function metadata named GUIDMetadataName.
LLVM Basic Block Representation.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOContextualProfile run(Module &M, ModuleAnalysisManager &MAM)
static InstrProfIncrementInst * getBBInstrumentation(BasicBlock &BB)
Get the instruction instrumenting a BB, or nullptr if not present.
static InstrProfIncrementInstStep * getSelectInstrumentation(SelectInst &SI)
Get the step instrumentation associated with a select
static void collectIndirectCallPromotionList(CallBase &IC, Result &Profile, SetVector< std::pair< CallBase *, Function * > > &Candidates)
static InstrProfCallsite * getCallsiteInstrumentation(CallBase &CB)
Get the instruction instrumenting a callsite, or nullptr if that cannot be found.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
This represents the llvm.instrprof.callsite intrinsic.
This represents the llvm.instrprof.increment.step intrinsic.
This represents the llvm.instrprof.increment intrinsic.
A Module instance is used to store all the information related to an LLVM module.
The instrumented contextual profile, produced by the CtxProfAnalysis.
void visit(ConstVisitor, const Function *F=nullptr) const
PGOContextualProfile(PGOContextualProfile &&)=default
const CtxProfFlatProfile flatten() const
const PGOCtxProfContext::CallTargetMapTy & profiles() const
void update(Visitor, const Function &F)
StringRef getFunctionName(GlobalValue::GUID GUID) const
bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
uint32_t getNumCounters(const Function &F) const
uint32_t allocateNextCounterIndex(const Function &F)
PGOContextualProfile(const PGOContextualProfile &)=delete
uint32_t getNumCallsites(const Function &F) const
uint32_t allocateNextCallsiteIndex(const Function &F)
bool isFunctionKnown(const Function &F) const
A node (context) in the loaded contextual profile, suitable for mutation during IPO passes.
std::map< GlobalValue::GUID, PGOCtxProfContext > CallTargetMapTy
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
This class represents the LLVM 'select' instruction.
A vector that has set insertion semantics.
StringRef - Represent a constant reference to a string, i.e.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
std::map< GlobalValue::GUID, SmallVector< uint64_t, 1 > > CtxProfFlatProfile
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A CRTP mix-in to automatically provide informational APIs needed for passes.