LLVM: lib/ProfileData/InstrProf.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "instrprof"
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)
#define INSTR_PROF_VISIBILITY
#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
#define INSTR_PROF_COMMA
#define VALUE_PROF_KIND(Enumerator, Value, Descr)
#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
#define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
#define COVINIT_FUNC(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_DATA_DEFINED
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)
#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
#define INSTR_PROF_COMMA
#define VALUE_PROF_KIND(Enumerator, Value, Descr)
#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
#define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
#define COVINIT_FUNC(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_DATA_DEFINED
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)
#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
#define INSTR_PROF_COMMA
#define VALUE_PROF_KIND(Enumerator, Value, Descr)
#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
#define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
#define COVINIT_FUNC(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_DATA_DEFINED
#define INSTR_PROF_COMMON_API_IMPL
#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VTABLE_DATA(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_VALUE_NODE(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer)
#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType)
#define INSTR_PROF_COMMA
#define VALUE_PROF_KIND(Enumerator, Value, Descr)
#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Initializer)
#define COVMAP_HEADER(Type, LLVMType, Name, Initializer)
#define COVINIT_FUNC(Type, LLVMType, Name, Initializer)
#define INSTR_PROF_DATA_DEFINED
#define INSTR_PROF_INLINE
#define INSTR_PROF_NULLPTR NULL
#define offsetof(TYPE, MEMBER)
Functions
static std::string getInstrProfErrString (instrprof_error Err, const std::string &ErrMsg="")
cl::opt< bool > llvm::DoInstrProfNameCompression ("enable-name-compression", cl::desc("Enable name/filename string compression"), cl::init(true))
LLVM_ABI std::string llvm::getInstrProfSectionName (InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
LLVM_ABI std::string llvm::getPGOFuncName (StringRef RawFuncName, GlobalValue::LinkageTypes Linkage, StringRef FileName, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Return the modified name for a function suitable to be used the key for profile lookup.
static StringRef llvm::stripDirPrefix (StringRef PathNameStr, uint32_t NumPrefix)
static StringRef llvm::getStrippedSourceFileName (const GlobalObject &GO)
static std::string llvm::getIRPGONameForGlobalObject (const GlobalObject &GO, GlobalValue::LinkageTypes Linkage, StringRef FileName)
static std::optional< std::string > llvm::lookupPGONameFromMetadata (MDNode *MD)
static std::string llvm::getIRPGOObjectName (const GlobalObject &GO, bool InLTO, MDNode *PGONameMetadata)
LLVM_ABI std::string llvm::getIRPGOFuncName (const Function &F, bool InLTO=false)
LLVM_ABI std::string llvm::getPGOFuncName (const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
Please use getIRPGOFuncName for LLVM IR instrumentation.
LLVM_ABI std::string llvm::getPGOName (const GlobalVariable &V, bool InLTO=false)
LLVM_ABI std::pair< StringRef, StringRef > llvm::getParsedIRPGOName (StringRef IRPGOName)
LLVM_ABI StringRef llvm::getFuncNameWithoutPrefix (StringRef PGOFuncName, StringRef FileName="")
Given a PGO function name, remove the filename prefix and return the original (static) function name.
LLVM_ABI std::string llvm::getPGOFuncNameVarName (StringRef FuncName, GlobalValue::LinkageTypes Linkage)
Return the name of the global variable used to store a function name in PGO instrumentation.
LLVM_ABI bool llvm::isGPUProfTarget (const Module &M)
Determines whether module targets a GPU eligable for PGO instrumentation.
void llvm::setPGOFuncVisibility (Module &M, GlobalVariable *FuncNameVar)
LLVM_ABI GlobalVariable * llvm::createPGOFuncNameVar (Module &M, GlobalValue::LinkageTypes Linkage, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
LLVM_ABI GlobalVariable * llvm::createPGOFuncNameVar (Function &F, StringRef PGOFuncName)
Create and return the global variable for function name used in PGO instrumentation.
LLVM_ABI Error llvm::readAndDecodeStrings (StringRef NameStrings, std::function< Error(StringRef)> NameCallback)
NameStrings is a string composed of one or more possibly encoded sub-strings.
LLVM_ABI Error llvm::collectGlobalObjectNameStrings (ArrayRef< std::string > NameStrs, bool doCompression, std::string &Result)
Given a vector of strings (names of global objects like functions or, virtual tables) NameStrs, the method generates a combined string Result that is ready to be serialized.
LLVM_ABI StringRef llvm::getPGOFuncNameVarInitializer (GlobalVariable *NameVar)
Return the initializer in string of the PGO name var NameVar.
LLVM_ABI Error llvm::collectPGOFuncNameStrings (ArrayRef< GlobalVariable * > NameVars, std::string &Result, bool doCompression=true)
Produce Result string with the same format described above.
LLVM_ABI Error llvm::collectVTableStrings (ArrayRef< GlobalVariable * > VTables, std::string &Result, bool doCompression)
llvm::INSTR_PROF_DATA (const uint64_t, llvm::Type::getInt64Ty(Ctx), NameRef, ConstantInt::get(llvm::Type::getInt64Ty(Ctx), IndexedInstrProf::ComputeHash(getPGOFuncNameVarInitializer(Inc->getName())))) INSTR_PROF_DATA(const uint64_t
FunctionAddr llvm::INSTR_PROF_DATA (IntPtrT, llvm::PointerType::getUnqual(Ctx), Values, ValuesPtrExpr) INSTR_PROF_DATA(const uint32_t
FunctionAddr VTableAddr llvm::INSTR_PROF_VTABLE_DATA (const uint32_t, llvm::Type::getInt32Ty(Ctx), VTableSize, ConstantInt::get(llvm::Type::getInt32Ty(Ctx), VTableSizeVal)) INSTR_PROF_VALUE_NODE(uint64_t
FunctionAddr VTableAddr uintptr_t llvm::CountersBegin (uintptr_t) DataBegin) INSTR_PROF_RAW_HEADER(uint64_t
FunctionAddr VTableAddr uintptr_t uintptr_t llvm::BitmapBegin (uintptr_t) DataBegin) VALUE_PROF_FUNC_PARAM(uint64_t
FunctionAddr VTableAddr uintptr_t uintptr_t WriteoutF llvm::COVINIT_FUNC (IntPtrT, llvm::PointerType::getUnqual(Ctx), ResetFunction, ResetF) typedef struct ValueProfRecord
This is the header of the data structure that defines the on-disk layout of the value profile data of a particular kind for one function.
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t llvm::getValueProfRecordSize (uint32_t NumValueSites, uint32_t NumValueData)
Return the total size of the value profile record including the header and the value data.
INSTR_PROF_VISIBILITY InstrProfValueData * llvm::getValueProfRecordValueData (ValueProfRecord *This)
Return the pointer to the start of value data array.
INSTR_PROF_VISIBILITY INSTR_PROF_INLINE uint32_t llvm::getValueProfRecordNumValueData (ValueProfRecord *This)
Return the total number of value data for This record.
INSTR_PROF_VISIBILITY ValueProfRecord * llvm::getValueProfRecordNext (ValueProfRecord *This)
Use this method to advance to the next This ValueProfRecord.
INSTR_PROF_VISIBILITY ValueProfRecord * llvm::getFirstValueProfRecord (ValueProfData *This)
Return the first ValueProfRecord instance.
INSTR_PROF_VISIBILITY uint32_t llvm::getValueProfDataSize (ValueProfRecordClosure *Closure)
Return the total size in bytes of the on-disk value profile data given the data stored in Record.
INSTR_PROF_VISIBILITY void llvm::serializeValueProfRecordFrom (ValueProfRecord *This, ValueProfRecordClosure *Closure, uint32_t ValueKind, uint32_t NumValueSites)
Extract value profile data of a function for the profile kind ValueKind from the Closure and serialize the data into This record instance.
INSTR_PROF_VISIBILITY ValueProfData * llvm::serializeValueProfDataFrom (ValueProfRecordClosure *Closure, ValueProfData *DstData)
Extract value profile data of a function from the Closure and serialize the data into DstData if it is not NULL or heap memory allocated by the Closure's allocator method.
uint32_t llvm::getNumValueKindsInstrProf (const void *Record)
ValueProfRecordClosure Interface implementation for InstrProfRecord class.
uint32_t llvm::getNumValueSitesInstrProf (const void *Record, uint32_t VKind)
uint32_t llvm::getNumValueDataInstrProf (const void *Record, uint32_t VKind)
uint32_t llvm::getNumValueDataForSiteInstrProf (const void *R, uint32_t VK, uint32_t S)
void llvm::getValueForSiteInstrProf (const void *R, InstrProfValueData *Dst, uint32_t K, uint32_t S)
ValueProfData * llvm::allocValueProfDataInstrProf (size_t TotalSizeInBytes)
static std::unique_ptr< ValueProfData > llvm::allocValueProfData (uint32_t TotalSize)
LLVM_ABI void llvm::annotateValueSite (Module &M, Instruction &Inst, const InstrProfRecord &InstrProfR, InstrProfValueKind ValueKind, uint32_t SiteIndx, uint32_t MaxMDCount=3)
Get the value profile data for value site SiteIdx from InstrProfR and annotate the instruction Inst with the value profile meta data.
LLVM_ABI void llvm::annotateValueSite (Module &M, Instruction &Inst, ArrayRef< InstrProfValueData > VDs, uint64_t Sum, InstrProfValueKind ValueKind, uint32_t MaxMDCount)
Same as the above interface but using an ArrayRef, as well as Sum.
MDNode * llvm::mayHaveValueProfileOfKind (const Instruction &Inst, InstrProfValueKind ValueKind)
LLVM_ABI SmallVector< InstrProfValueData, 4 > llvm::getValueProfDataFromInst (const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
Extract the value profile data from Inst and returns them if Inst is annotated with value profile data.
LLVM_ABI MDNode * llvm::getPGOFuncNameMetadata (const Function &F)
Return the PGOFuncName meta data associated with a function.
static void llvm::createPGONameMetadata (GlobalObject &GO, StringRef MetadataName, StringRef PGOName)
LLVM_ABI void llvm::createPGOFuncNameMetadata (Function &F, StringRef PGOFuncName)
Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
LLVM_ABI void llvm::createPGONameMetadata (GlobalObject &GO, StringRef PGOName)
Create the PGOName metadata if a global object's PGO name is different from its mangled name.
LLVM_ABI bool llvm::needsComdatForCounter (const GlobalObject &GV, const Module &M)
Check if we can use Comdat for profile variables.
LLVM_ABI bool llvm::isIRPGOFlagSet (const Module *M)
Check if INSTR_PROF_RAW_VERSION_VAR is defined.
LLVM_ABI bool llvm::canRenameComdatFunc (const Function &F, bool CheckAddressTaken=false)
Check if we can safely rename this Comdat function.
LLVM_ABI void llvm::createProfileFileNameVar (Module &M, StringRef InstrProfileOutput)
Variables
static cl::opt< bool > StaticFuncFullModulePrefix ("static-func-full-module-prefix", cl::init(true), cl::Hidden, cl::desc("Use full module build paths in the profile counter names for " "static functions."))
static cl::opt< unsigned > StaticFuncStripDirNamePrefix ("static-func-strip-dirname-prefix", cl::init(0), cl::Hidden, cl::desc("Strip specified level of directory name from source path in " "the profile counter name for static functions."))
cl::opt< bool > llvm::EnableVTableValueProfiling ("enable-vtable-value-profiling", cl::init(false), cl::desc("If true, the virtual table address will be instrumented to know " "the types of a C++ pointer. The information is used in indirect " "call promotion to do selective vtable-based comparison."))
cl::opt< bool > llvm::EnableVTableProfileUse ("enable-vtable-profile-use", cl::init(false), cl::desc("If ThinLTO and WPD is enabled and this option is true, vtable " "profiles will be used by ICP pass for more efficient indirect " "call sequence. If false, type profiles won't be used."))
static ValueProfRecordClosure llvm::InstrProfRecordClosure

COVINIT_FUNC [1/4]

#define COVINIT_FUNC ( Type,
LLVMType,
Name,
Initializer )

COVINIT_FUNC [2/4]

#define COVINIT_FUNC ( Type,
LLVMType,
Name,
Initializer )

COVINIT_FUNC [3/4]

#define COVINIT_FUNC ( Type,
LLVMType,
Name,
Initializer )

COVINIT_FUNC [4/4]

#define COVINIT_FUNC ( Type,
LLVMType,
Name,
Initializer )

COVMAP_FUNC_RECORD [1/4]

#define COVMAP_FUNC_RECORD ( Type,
LLVMType,
Name,
Initializer )

COVMAP_FUNC_RECORD [2/4]

#define COVMAP_FUNC_RECORD ( Type,
LLVMType,
Name,
Initializer )

COVMAP_FUNC_RECORD [3/4]

#define COVMAP_FUNC_RECORD ( Type,
LLVMType,
Name,
Initializer )

COVMAP_FUNC_RECORD [4/4]

#define COVMAP_FUNC_RECORD ( Type,
LLVMType,
Name,
Initializer )

COVMAP_HEADER [1/4]

#define COVMAP_HEADER ( Type,
LLVMType,
Name,
Initializer )

COVMAP_HEADER [2/4]

#define COVMAP_HEADER ( Type,
LLVMType,
Name,
Initializer )

COVMAP_HEADER [3/4]

#define COVMAP_HEADER ( Type,
LLVMType,
Name,
Initializer )

COVMAP_HEADER [4/4]

#define COVMAP_HEADER ( Type,
LLVMType,
Name,
Initializer )

DEBUG_TYPE

#define DEBUG_TYPE "instrprof"

INSTR_PROF_COMMA [1/4]

INSTR_PROF_COMMA [2/4]

INSTR_PROF_COMMA [3/4]

INSTR_PROF_COMMA [4/4]

INSTR_PROF_COMMON_API_IMPL

#define INSTR_PROF_COMMON_API_IMPL

INSTR_PROF_DATA [1/4]

#define INSTR_PROF_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_DATA [2/4]

#define INSTR_PROF_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_DATA [3/4]

#define INSTR_PROF_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_DATA [4/4]

#define INSTR_PROF_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_DATA_DEFINED [1/4]

#define INSTR_PROF_DATA_DEFINED

INSTR_PROF_DATA_DEFINED [2/4]

#define INSTR_PROF_DATA_DEFINED

INSTR_PROF_DATA_DEFINED [3/4]

#define INSTR_PROF_DATA_DEFINED

INSTR_PROF_DATA_DEFINED [4/4]

#define INSTR_PROF_DATA_DEFINED

INSTR_PROF_INLINE

#define INSTR_PROF_INLINE

INSTR_PROF_NULLPTR

#define INSTR_PROF_NULLPTR NULL

INSTR_PROF_RAW_HEADER [1/4]

#define INSTR_PROF_RAW_HEADER ( Type,
Name,
Initializer )

INSTR_PROF_RAW_HEADER [2/4]

#define INSTR_PROF_RAW_HEADER ( Type,
Name,
Initializer )

INSTR_PROF_RAW_HEADER [3/4]

#define INSTR_PROF_RAW_HEADER ( Type,
Name,
Initializer )

INSTR_PROF_RAW_HEADER [4/4]

#define INSTR_PROF_RAW_HEADER ( Type,
Name,
Initializer )

INSTR_PROF_SECT_ENTRY [1/3]

#define INSTR_PROF_SECT_ENTRY ( Kind,
SectNameCommon,
SectNameCoff,
Prefix )

INSTR_PROF_SECT_ENTRY [2/3]

#define INSTR_PROF_SECT_ENTRY ( Kind,
SectNameCommon,
SectNameCoff,
Prefix )

INSTR_PROF_SECT_ENTRY [3/3]

#define INSTR_PROF_SECT_ENTRY ( Kind,
SectNameCommon,
SectNameCoff,
Prefix )

INSTR_PROF_VALUE_NODE [1/4]

#define INSTR_PROF_VALUE_NODE ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VALUE_NODE [2/4]

#define INSTR_PROF_VALUE_NODE ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VALUE_NODE [3/4]

#define INSTR_PROF_VALUE_NODE ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VALUE_NODE [4/4]

#define INSTR_PROF_VALUE_NODE ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VISIBILITY

#define INSTR_PROF_VISIBILITY

INSTR_PROF_VTABLE_DATA [1/4]

#define INSTR_PROF_VTABLE_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VTABLE_DATA [2/4]

#define INSTR_PROF_VTABLE_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VTABLE_DATA [3/4]

#define INSTR_PROF_VTABLE_DATA ( Type,
LLVMType,
Name,
Initializer )

INSTR_PROF_VTABLE_DATA [4/4]

#define INSTR_PROF_VTABLE_DATA ( Type,
LLVMType,
Name,
Initializer )

offsetof

#define offsetof ( TYPE,
MEMBER )

Value:

((size_t) &((TYPE *)0)->MEMBER)

Referenced by llvm::cas::ondisk::TableHandle::check(), llvm::gsym::GsymCreator::encode(), llvm::AppleAcceleratorTable::extract(), getAuxMaxAlignment(), llvm::object::MachOObjectFile::getChainedFixupsSegments(), llvm::SmallVectorTemplateCommon< T, typename >::getFirstEl(), llvm::object::ArchiveMemberHeader::getName(), llvm::object::MachOObjectFile::getUuid(), llvm::identify_magic(), and llvm::DynamicAPInt::static_assert_layout().

VALUE_PROF_FUNC_PARAM [1/4]

#define VALUE_PROF_FUNC_PARAM ( ArgType,
ArgName,
ArgLLVMType )

VALUE_PROF_FUNC_PARAM [2/4]

#define VALUE_PROF_FUNC_PARAM ( ArgType,
ArgName,
ArgLLVMType )

VALUE_PROF_FUNC_PARAM [3/4]

#define VALUE_PROF_FUNC_PARAM ( ArgType,
ArgName,
ArgLLVMType )

VALUE_PROF_FUNC_PARAM [4/4]

#define VALUE_PROF_FUNC_PARAM ( ArgType,
ArgName,
ArgLLVMType )

VALUE_PROF_KIND [1/4]

#define VALUE_PROF_KIND ( Enumerator,
Value,
Descr )

VALUE_PROF_KIND [2/4]

#define VALUE_PROF_KIND ( Enumerator,
Value,
Descr )

VALUE_PROF_KIND [3/4]

#define VALUE_PROF_KIND ( Enumerator,
Value,
Descr )

VALUE_PROF_KIND [4/4]

#define VALUE_PROF_KIND ( Enumerator,
Value,
Descr )

getInstrProfErrString()

Definition at line 82 of file InstrProf.cpp.

References llvm::bad_header, llvm::bad_magic, llvm::bitmap_mismatch, llvm::compress_failed, llvm::count_mismatch, llvm::counter_overflow, llvm::counter_value_too_large, llvm::empty_raw_profile, llvm::eof, llvm::hash_mismatch, llvm::invalid_prof, llvm::malformed, llvm::missing_correlation_info, llvm::raw_profile_version_mismatch, llvm::raw_string_ostream::str(), llvm::success, llvm::too_large, llvm::truncated, llvm::unable_to_correlate_profile, llvm::uncompress_failed, llvm::unexpected_correlation_info, llvm::unknown_function, llvm::unrecognized_format, llvm::unsupported_hash_type, llvm::unsupported_version, llvm::value_site_count_mismatch, and llvm::zlib_unavailable.

Referenced by llvm::InstrProfError::message().

StaticFuncFullModulePrefix

cl::opt< bool > StaticFuncFullModulePrefix("static-func-full-module-prefix", cl::init(true), cl::Hidden, cl::desc("Use full module build paths in the profile counter names for " "static functions.")) ( "static-func-full-module-prefix" , cl::init(true) , cl::Hidden , cl::desc("Use full module build paths in the profile counter names for " "static functions.") ) static

StaticFuncStripDirNamePrefix

cl::opt< unsigned > StaticFuncStripDirNamePrefix("static-func-strip-dirname-prefix", cl::init(0), cl::Hidden, cl::desc("Strip specified level of directory name from source path in " "the profile counter name for static functions.")) ( "static-func-strip-dirname-prefix" , cl::init(0) , cl::Hidden , cl::desc("Strip specified level of directory name from source path in " "the profile counter name for static functions.") ) static