clang API Documentation

Public Member Functions | Static Public Member Functions | Friends
clang::CodeGen::CodeGenPGO Class Reference

#include <CodeGenPGO.h>

List of all members.

Public Member Functions

 CodeGenPGO (CodeGenModule &CGM)
bool haveRegionCounts () const
StringRef getFuncName () const
std::string getFuncVarName (StringRef VarName) const
uint64_t getCurrentRegionCount () const
 Return the counter value of the current region.
void setCurrentRegionCount (uint64_t Count)
void setCurrentRegionUnreachable ()
bool getStmtCount (const Stmt *S, uint64_t &Count)
void setCurrentStmt (const Stmt *S)
llvm::MDNode * createBranchWeights (uint64_t TrueCount, uint64_t FalseCount)
 Calculate branch weights appropriate for PGO data.
llvm::MDNode * createBranchWeights (ArrayRef< uint64_t > Weights)
llvm::MDNode * createLoopWeights (const Stmt *Cond, RegionCounter &Cnt)
void checkGlobalDecl (GlobalDecl GD)
 Check if we need to emit coverage mapping for a given declaration.
void assignRegionCounters (const Decl *D, llvm::Function *Fn)
void emitInstrumentationData ()
 Emit static data structures for instrumentation data.
void destroyRegionCounters ()
void emitEmptyCounterMapping (const Decl *D, StringRef FuncName, llvm::GlobalValue::LinkageTypes Linkage)

Static Public Member Functions

static llvm::Function * emitInitialization (CodeGenModule &CGM)
 Emit static initialization code, if any.

Friends

class RegionCounter

Detailed Description

Per-function PGO state. This class should generally not be used directly, but instead through the CodeGenFunction and RegionCounter types.

Definition at line 31 of file CodeGenPGO.h.


Constructor & Destructor Documentation

Definition at line 51 of file CodeGenPGO.h.


Member Function Documentation

void CodeGenPGO::assignRegionCounters ( const Decl D,
llvm::Function *  Fn 
)

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.

Definition at line 858 of file CodeGenPGO.cpp.

References clang::CodeGen::CodeGenModule::ClearUnusedCoverageMapping(), emitRuntimeHook(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenModule::getContext(), clang::Decl::getLocation(), clang::CodeGen::CodeGenModule::getPGOReader(), clang::ASTContext::getSourceManager(), clang::Decl::isImplicit(), clang::SourceManager::isInMainFile(), and SM.

Referenced by clang::CodeGen::CodeGenFunction::GenerateCapturedStmtFunction(), clang::CodeGen::CodeGenFunction::GenerateCode(), and clang::CodeGen::CodeGenFunction::GenerateObjCMethod().

Check if we need to emit coverage mapping for a given declaration.

Definition at line 844 of file CodeGenPGO.cpp.

References clang::Ctor_Base, clang::Dtor_Base, clang::GlobalDecl::getCtorType(), clang::GlobalDecl::getDecl(), and clang::GlobalDecl::getDtorType().

Referenced by clang::CodeGen::CodeGenFunction::GenerateCode().

llvm::MDNode * CodeGenPGO::createBranchWeights ( uint64_t  TrueCount,
uint64_t  FalseCount 
)
llvm::MDNode * CodeGenPGO::createBranchWeights ( ArrayRef< uint64_t >  Weights)
llvm::MDNode * CodeGenPGO::createLoopWeights ( const Stmt Cond,
RegionCounter Cnt 
)

Clean up region counter state. Must be called if assignRegionCounters is used.

Definition at line 1008 of file CodeGenPGO.cpp.

Referenced by clang::CodeGen::CodeGenFunction::GenerateCapturedStmtFunction(), clang::CodeGen::CodeGenFunction::GenerateCode(), and clang::CodeGen::CodeGenFunction::GenerateObjCMethod().

void CodeGenPGO::emitEmptyCounterMapping ( const Decl D,
StringRef  FuncName,
llvm::GlobalValue::LinkageTypes  Linkage 
)
llvm::Function * CodeGenPGO::emitInitialization ( CodeGenModule CGM) [static]
StringRef clang::CodeGen::CodeGenPGO::getFuncName ( ) const [inline]

Get the string used to identify this function in the profile data. For functions with local linkage, this includes the main file name.

Definition at line 63 of file CodeGenPGO.h.

std::string clang::CodeGen::CodeGenPGO::getFuncVarName ( StringRef  VarName) const [inline]

Definition at line 64 of file CodeGenPGO.h.

bool clang::CodeGen::CodeGenPGO::getStmtCount ( const Stmt S,
uint64_t &  Count 
) [inline]

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

Definition at line 83 of file CodeGenPGO.h.

Referenced by createLoopWeights(), and setCurrentStmt().

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.

Definition at line 59 of file CodeGenPGO.h.

Referenced by createLoopWeights(), and clang::CodeGen::CodeGenFunction::EmitSwitchStmt().

void clang::CodeGen::CodeGenPGO::setCurrentRegionCount ( uint64_t  Count) [inline]

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.

Definition at line 74 of file CodeGenPGO.h.

References clang::LangAS::Count.

Referenced by clang::CodeGen::RegionCounter::applyAdjustmentsToRegion(), clang::CodeGen::RegionCounter::beginElseRegion(), clang::CodeGen::RegionCounter::beginRegion(), clang::CodeGen::RegionCounter::setCurrentRegionCount(), setCurrentRegionUnreachable(), and setCurrentStmt().

Indicate that the current region is never reached, and thus should have a counter value of zero. This is important so that subsequent regions can correctly track their parent counts.

Definition at line 79 of file CodeGenPGO.h.

References setCurrentRegionCount().

void clang::CodeGen::CodeGenPGO::setCurrentStmt ( const Stmt S) [inline]

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

Definition at line 96 of file CodeGenPGO.h.

References clang::LangAS::Count, getStmtCount(), and setCurrentRegionCount().

Referenced by clang::CodeGen::CodeGenFunction::EmitStmt(), and clang::CodeGen::CodeGenFunction::EvaluateExprAsBool().


Friends And Related Function Documentation

friend class RegionCounter [friend]

Definition at line 157 of file CodeGenPGO.h.


The documentation for this class was generated from the following files: