13 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H 14 #define LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H 19 #include "llvm/ProfileData/InstrProfReader.h" 31 llvm::GlobalVariable *FuncNameVar;
33 std::array <unsigned, llvm::IPVK_Last + 1> NumValueSites;
34 unsigned NumRegionCounters;
35 uint64_t FunctionHash;
36 std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>> RegionCounterMap;
37 std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap;
38 std::unique_ptr<llvm::InstrProfRecord> ProfRecord;
39 std::vector<uint64_t> RegionCounts;
40 uint64_t CurrentRegionCount;
44 : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), FunctionHash(0),
45 CurrentRegionCount(0) {}
65 auto I = StmtCountMap->find(S);
66 if (I == StmtCountMap->end())
86 llvm::GlobalValue::LinkageTypes
Linkage);
89 llvm::Instruction *ValueSite,
llvm::Value *ValuePtr);
91 void setFuncName(llvm::Function *Fn);
92 void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes Linkage);
93 void mapRegionCounters(
const Decl *D);
94 void computeRegionCounts(
const Decl *D);
95 void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
97 void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
99 bool skipRegionMappingForDecl(
const Decl *D);
100 void emitCounterRegionMapping(
const Decl *D);
108 if (!RegionCounterMap)
112 return RegionCounts[(*RegionCounterMap)[S]];
Optional< uint64_t > getStmtCount(const Stmt *S)
Check if an execution count is known for a given statement.
Stmt - This represents one statement.
Decl - This represents one declaration (or definition), e.g.
void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S, llvm::Value *StepV)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
void setCurrentRegionCount(uint64_t Count)
Set the counter value for the current region.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
void valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, llvm::Instruction *ValueSite, llvm::Value *ValuePtr)
GlobalDecl - represents a global declaration.
uint64_t getCurrentRegionCount() const
Return the counter value of the current region.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
void emitEmptyCounterMapping(const Decl *D, StringRef FuncName, llvm::GlobalValue::LinkageTypes Linkage)
Emit a coverage mapping range with a counter zero for an unused declaration.
void setCurrentStmt(const Stmt *S)
If the execution count for the current statement is known, record that as the current count...
uint64_t getRegionCount(const Stmt *S)
Return the region count for the counter at the given index.
bool haveRegionCounts() const
Whether or not we have PGO region data for the current function.
CodeGenPGO(CodeGenModule &CGM)