13 #ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
14 #define LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
19 #include "llvm/ProfileData/InstrProfReader.h"
32 llvm::GlobalVariable *FuncNameVar;
34 std::array <unsigned, llvm::IPVK_Last + 1> NumValueSites;
35 unsigned NumRegionCounters;
37 std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>> RegionCounterMap;
38 std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap;
39 std::unique_ptr<llvm::InstrProfRecord> ProfRecord;
40 std::vector<uint64_t> RegionCounts;
45 : CGM(CGModule), FuncNameVar(nullptr), NumValueSites({{0}}),
46 NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0) {}
66 auto I = StmtCountMap->find(S);
67 if (I == StmtCountMap->end())
87 llvm::GlobalValue::LinkageTypes
Linkage);
90 llvm::Instruction *ValueSite, llvm::Value *ValuePtr);
96 void setFuncName(llvm::Function *Fn);
97 void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes
Linkage);
98 void mapRegionCounters(
const Decl *D);
99 void computeRegionCounts(
const Decl *D);
100 void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
102 void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
104 bool skipRegionMappingForDecl(
const Decl *D);
105 void emitCounterRegionMapping(
const Decl *D);
113 if (!RegionCounterMap)
117 return RegionCounts[(*RegionCounterMap)[S]];