class CodeGenPGO

Declaration

class CodeGenPGO { /* full declaration omitted */ };

Description

Per-function PGO state.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:27

Member Variables

private clang::CodeGen::CodeGenModule& CGM
private std::string FuncName
private llvm::GlobalVariable* FuncNameVar
private std::array<unsigned int, llvm::IPVK_Last + 1> NumValueSites
private unsigned int NumRegionCounters
private uint64_t FunctionHash
private std::unique_ptr< llvm::DenseMap<const Stmt*, unsigned int>> RegionCounterMap
private std::unique_ptr< llvm::DenseMap<const Stmt*, uint64_t>> StmtCountMap
private std::unique_ptr<llvm::InstrProfRecord> ProfRecord
private std::vector<uint64_t> RegionCounts
private uint64_t CurrentRegionCount

Method Overview

Methods

CodeGenPGO(
    clang::CodeGen::CodeGenModule& CGModule)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:43

Parameters

clang::CodeGen::CodeGenModule& CGModule

void applyFunctionAttributes(
    llvm::IndexedInstrProfReader* PGOReader,
    llvm::Function* Fn)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:99

Parameters

llvm::IndexedInstrProfReader* PGOReader
llvm::Function* Fn

void assignRegionCounters(clang::GlobalDecl GD,
                          llvm::Function* Fn)

Description

Assign counters to regions and configure them for PGO of a given function. Does nothing if instrumentation is not enabled and either generates global variables or associates PGO data with each of the counters depending on whether we are generating or using instrumentation.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:82

Parameters

clang::GlobalDecl GD
llvm::Function* Fn

void computeRegionCounts(const clang::Decl* D)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:98

Parameters

const clang::Decl* D

void emitCounterIncrement(
    clang::CodeGen::CGBuilderTy& Builder,
    const clang::Stmt* S,
    llvm::Value* StepV)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:107

Parameters

clang::CodeGen::CGBuilderTy& Builder
const clang::Stmt* S
llvm::Value* StepV

void emitCounterRegionMapping(
    const clang::Decl* D)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:104

Parameters

const clang::Decl* D

void emitEmptyCounterMapping(
    const clang::Decl* D,
    llvm::StringRef FuncName,
    llvm::GlobalValue::LinkageTypes Linkage)

Description

Emit a coverage mapping range with a counter zero for an unused declaration.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:85

Parameters

const clang::Decl* D
llvm::StringRef FuncName
llvm::GlobalValue::LinkageTypes Linkage

uint64_t getCurrentRegionCount() const

Description

Return the counter value of the current region.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:53

uint64_t getRegionCount(const clang::Stmt* S)

Description

Return the region count for the counter at the given index.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:111

Parameters

const clang::Stmt* S

Optional<uint64_t> getStmtCount(
    const clang::Stmt* S) const

Description

Check if an execution count is known for a given statement. If so, return true and put the value in Count; else return false.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:62

Parameters

const clang::Stmt* S

bool haveRegionCounts() const

Description

Whether or not we have PGO region data for the current function. This is false both when we have no data at all and when our data has been discarded.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:50

void loadRegionCounts(
    llvm::IndexedInstrProfReader* PGOReader,
    bool IsInMainFile)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:101

Parameters

llvm::IndexedInstrProfReader* PGOReader
bool IsInMainFile

void mapRegionCounters(const clang::Decl* D)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:97

Parameters

const clang::Decl* D

void setCurrentRegionCount(uint64_t Count)

Description

Set the counter value for the current region. This is used to keep track of changes to the most recent counter from control flow and non-local exits.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:58

Parameters

uint64_t Count

void setCurrentStmt(const clang::Stmt* S)

Description

If the execution count for the current statement is known, record that as the current count.

Declared at: clang/lib/CodeGen/CodeGenPGO.h:73

Parameters

const clang::Stmt* S

void setFuncName(
    llvm::StringRef Name,
    llvm::GlobalValue::LinkageTypes Linkage)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:96

Parameters

llvm::StringRef Name
llvm::GlobalValue::LinkageTypes Linkage

void setFuncName(llvm::Function* Fn)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:95

Parameters

llvm::Function* Fn

void setValueProfilingFlag(llvm::Module& M)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:92

Parameters

llvm::Module& M

bool skipRegionMappingForDecl(
    const clang::Decl* D)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:103

Parameters

const clang::Decl* D

void valueProfile(
    clang::CodeGen::CGBuilderTy& Builder,
    uint32_t ValueKind,
    llvm::Instruction* ValueSite,
    llvm::Value* ValuePtr)

Declared at: clang/lib/CodeGen/CodeGenPGO.h:88

Parameters

clang::CodeGen::CGBuilderTy& Builder
uint32_t ValueKind
llvm::Instruction* ValueSite
llvm::Value* ValuePtr