14 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/Support/MemoryBuffer.h"
33 llvm::GlobalVariable *FuncNameVar;
35 unsigned NumRegionCounters;
36 uint64_t FunctionHash;
37 std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>> RegionCounterMap;
38 std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap;
39 std::vector<uint64_t> RegionCounts;
40 uint64_t CurrentRegionCount;
43 bool SkipCoverageMapping;
47 : CGM(CGM), NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0),
48 SkipCoverageMapping(
false) {}
68 auto I = StmtCountMap->find(S);
69 if (I == StmtCountMap->end())
91 llvm::GlobalValue::LinkageTypes
Linkage);
93 void setFuncName(llvm::Function *Fn);
94 void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes
Linkage);
95 void createFuncNameVar(llvm::GlobalValue::LinkageTypes
Linkage);
96 void mapRegionCounters(
const Decl *D);
97 void computeRegionCounts(
const Decl *D);
98 void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
100 void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
102 void emitCounterVariables();
103 void emitCounterRegionMapping(
const Decl *D);
110 if (!RegionCounterMap)
114 return RegionCounts[(*RegionCounterMap)[
S]];
Optional< uint64_t > getStmtCount(const Stmt *S)
void checkGlobalDecl(GlobalDecl GD)
Check if we need to emit coverage mapping for a given declaration.
void emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S)
uint64_t getCurrentRegionCount() const
Return the counter value of the current region.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
void setCurrentRegionCount(uint64_t Count)
bool haveRegionCounts() const
llvm::IRBuilder< PreserveNames, llvm::ConstantFolder, CGBuilderInserterTy > CGBuilderTy
void emitEmptyCounterMapping(const Decl *D, StringRef FuncName, llvm::GlobalValue::LinkageTypes Linkage)
void setCurrentStmt(const Stmt *S)
BoundNodesTreeBuilder *const Builder
uint64_t getRegionCount(const Stmt *S)
Return the region count for the counter at the given index.
void assignRegionCounters(const Decl *D, llvm::Function *Fn)
CodeGenPGO(CodeGenModule &CGM)