13#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
14#define LLVM_CLANG_LIB_CODEGEN_CODEGENPGO_H
20#include "llvm/ProfileData/InstrProfReader.h"
33 llvm::GlobalVariable *FuncNameVar;
35 std::array <unsigned, llvm::IPVK_Last + 1> NumValueSites;
36 unsigned NumRegionCounters;
37 uint64_t FunctionHash;
38 std::unique_ptr<llvm::DenseMap<const Stmt *, unsigned>> RegionCounterMap;
39 std::unique_ptr<llvm::DenseMap<const Stmt *, uint64_t>> StmtCountMap;
40 std::unique_ptr<llvm::InstrProfRecord> ProfRecord;
41 std::unique_ptr<MCDC::State> RegionMCDCState;
42 std::vector<uint64_t> RegionCounts;
43 uint64_t CurrentRegionCount;
47 : CGM(CGModule), FuncNameVar(nullptr), NumValueSites({{0}}),
48 NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0) {}
68 auto I = StmtCountMap->find(S);
69 if (I == StmtCountMap->end())
89 llvm::GlobalValue::LinkageTypes
Linkage);
92 llvm::Instruction *ValueSite, llvm::Value *ValuePtr);
100 void setFuncName(llvm::Function *Fn);
101 void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes
Linkage);
102 void mapRegionCounters(
const Decl *
D);
103 void computeRegionCounts(
const Decl *
D);
104 void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
106 void loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
108 bool skipRegionMappingForDecl(
const Decl *
D);
109 void emitCounterRegionMapping(
const Decl *
D);
110 bool canEmitMCDCCoverage(
const CGBuilderTy &Builder);
122 Address MCDCCondBitmapAddr, llvm::Value *Val,
127 if (!RegionCounterMap)
133 auto Index = (*RegionCounterMap)[S];
134 if (Index >= RegionCounts.size())
136 return RegionCounts[Index];
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
std::optional< uint64_t > getStmtCount(const Stmt *S) const
Check if an execution count is known for a given statement.
void emitMCDCTestVectorBitmapUpdate(CGBuilderTy &Builder, const Expr *S, Address MCDCCondBitmapAddr, CodeGenFunction &CGF)
void setCurrentRegionCount(uint64_t Count)
Set the counter value for the current region.
uint64_t getRegionCount(const Stmt *S)
Return the region count for the counter at the given index.
void setValueProfilingFlag(llvm::Module &M)
void valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, llvm::Instruction *ValueSite, llvm::Value *ValuePtr)
void emitMCDCCondBitmapUpdate(CGBuilderTy &Builder, const Expr *S, Address MCDCCondBitmapAddr, llvm::Value *Val, CodeGenFunction &CGF)
void emitMCDCCondBitmapReset(CGBuilderTy &Builder, const Expr *S, Address MCDCCondBitmapAddr)
uint64_t getCurrentRegionCount() const
Return the counter value of the current region.
void setProfileVersion(llvm::Module &M)
void setCurrentStmt(const Stmt *S)
If the execution count for the current statement is known, record that as the current count.
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 emitMCDCParameters(CGBuilderTy &Builder)
CodeGenPGO(CodeGenModule &CGModule)
bool haveRegionCounts() const
Whether or not we have PGO region data for the current function.
void emitCounterSetOrIncrement(CGBuilderTy &Builder, const Stmt *S, llvm::Value *StepV)
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
GlobalDecl - represents a global declaration.
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.