#include "CodeGenPGO.h"
#include "CodeGenFunction.h"
#include "CoverageMappingGen.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtVisitor.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MD5.h"
#include <optional>
namespace llvm {
extern cl::opt<bool> EnableSingleByteCoverage;
}
static llvm::cl::opt<bool>
EnableValueProfiling("enable-value-profiling",
llvm::cl::desc("Enable value profiling"),
llvm::cl::Hidden, llvm::cl::init(false));
usingnamespaceclang;
usingnamespaceCodeGen;
void CodeGenPGO::setFuncName(StringRef Name,
llvm::GlobalValue::LinkageTypes Linkage) { … }
void CodeGenPGO::setFuncName(llvm::Function *Fn) { … }
enum PGOHashVersion : unsigned { … };
namespace {
class PGOHash { … };
const int PGOHash::NumBitsPerType;
const unsigned PGOHash::NumTypesPerWord;
const unsigned PGOHash::TooBig;
static PGOHashVersion getPGOHashVersion(llvm::IndexedInstrProfReader *PGOReader,
CodeGenModule &CGM) { … }
struct MapRegionCounters : public RecursiveASTVisitor<MapRegionCounters> { … };
struct ComputeRegionCounts : public ConstStmtVisitor<ComputeRegionCounts> { … };
}
void PGOHash::combine(HashType Type) { … }
uint64_t PGOHash::finalize() { … }
void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) { … }
void CodeGenPGO::mapRegionCounters(const Decl *D) { … }
bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { … }
void CodeGenPGO::emitCounterRegionMapping(const Decl *D) { … }
void
CodeGenPGO::emitEmptyCounterMapping(const Decl *D, StringRef Name,
llvm::GlobalValue::LinkageTypes Linkage) { … }
void CodeGenPGO::computeRegionCounts(const Decl *D) { … }
void
CodeGenPGO::applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,
llvm::Function *Fn) { … }
void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy &Builder, const Stmt *S,
llvm::Value *StepV) { … }
bool CodeGenPGO::canEmitMCDCCoverage(const CGBuilderTy &Builder) { … }
void CodeGenPGO::emitMCDCParameters(CGBuilderTy &Builder) { … }
void CodeGenPGO::emitMCDCTestVectorBitmapUpdate(CGBuilderTy &Builder,
const Expr *S,
Address MCDCCondBitmapAddr,
CodeGenFunction &CGF) { … }
void CodeGenPGO::emitMCDCCondBitmapReset(CGBuilderTy &Builder, const Expr *S,
Address MCDCCondBitmapAddr) { … }
void CodeGenPGO::emitMCDCCondBitmapUpdate(CGBuilderTy &Builder, const Expr *S,
Address MCDCCondBitmapAddr,
llvm::Value *Val,
CodeGenFunction &CGF) { … }
void CodeGenPGO::setValueProfilingFlag(llvm::Module &M) { … }
void CodeGenPGO::setProfileVersion(llvm::Module &M) { … }
void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind,
llvm::Instruction *ValueSite, llvm::Value *ValuePtr) { … }
void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader,
bool IsInMainFile) { … }
static uint64_t calculateWeightScale(uint64_t MaxWeight) { … }
static uint32_t scaleBranchWeight(uint64_t Weight, uint64_t Scale) { … }
llvm::MDNode *CodeGenFunction::createProfileWeights(uint64_t TrueCount,
uint64_t FalseCount) const { … }
llvm::MDNode *
CodeGenFunction::createProfileWeights(ArrayRef<uint64_t> Weights) const { … }
llvm::MDNode *
CodeGenFunction::createProfileWeightsForLoop(const Stmt *Cond,
uint64_t LoopCount) const { … }