LLVM 19.0.0git
Namespaces | Macros | Functions | Variables
InstrProf.cpp File Reference
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/config.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <system_error>
#include <type_traits>
#include <utility>
#include <vector>
#include "llvm/ProfileData/InstrProfData.inc"

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::IndexedInstrProf
 

Macros

#define DEBUG_TYPE   "instrprof"
 
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)    SectNameCommon,
 
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)    SectNameCoff,
 
#define INSTR_PROF_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix)    Prefix,
 
#define INSTR_PROF_COMMON_API_IMPL
 

Functions

static std::string getInstrProfErrString (instrprof_error Err, const std::string &ErrMsg="")
 
cl::opt< boolllvm::DoInstrProfNameCompression ("enable-name-compression", cl::desc("Enable name/filename string compression"), cl::init(true))
 
std::string llvm::getInstrProfSectionName (InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
 Return the name of the profile section corresponding to IPSK.
 
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)
 
std::string llvm::getIRPGOFuncName (const Function &F, bool InLTO=false)
 
std::string llvm::getPGOFuncName (const Function &F, bool InLTO=false, uint64_t Version=INSTR_PROF_INDEX_VERSION)
 Please use getIRPGOFuncName for LLVM IR instrumentation.
 
std::string llvm::getPGOName (const GlobalVariable &V, bool InLTO=false)
 
std::pair< StringRef, StringRefllvm::getParsedIRPGOName (StringRef IRPGOName)
 
StringRef llvm::getFuncNameWithoutPrefix (StringRef PGOFuncName, StringRef FileName="<unknown>")
 Given a PGO function name, remove the filename prefix and return the original (static) function name.
 
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.
 
GlobalVariablellvm::createPGOFuncNameVar (Module &M, GlobalValue::LinkageTypes Linkage, StringRef PGOFuncName)
 Create and return the global variable for function name used in PGO instrumentation.
 
GlobalVariablellvm::createPGOFuncNameVar (Function &F, StringRef PGOFuncName)
 Create and return the global variable for function name used in PGO instrumentation.
 
static Error llvm::readAndDecodeStrings (StringRef NameStrings, std::function< Error(StringRef)> NameCallback)
 NameStrings is a string composed of one of more possibly encoded sub-strings.
 
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.
 
StringRef llvm::getPGOFuncNameVarInitializer (GlobalVariable *NameVar)
 Return the initializer in string of the PGO name var NameVar.
 
Error llvm::collectPGOFuncNameStrings (ArrayRef< GlobalVariable * > NameVars, std::string &Result, bool doCompression=true)
 Produce Result string with the same format described above.
 
Error llvm::collectVTableStrings (ArrayRef< GlobalVariable * > VTables, std::string &Result, bool doCompression)
 
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)
 
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.
 
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.
 
MDNodellvm::mayHaveValueProfileOfKind (const Instruction &Inst, InstrProfValueKind ValueKind)
 
static bool llvm::getValueProfDataFromInstImpl (const MDNode *const MD, const uint32_t MaxNumDataWant, InstrProfValueData ValueData[], uint32_t &ActualNumValueData, uint64_t &TotalC, bool GetNoICPValue)
 
std::unique_ptr< InstrProfValueData[]> llvm::getValueProfDataFromInst (const Instruction &Inst, InstrProfValueKind ValueKind, uint32_t MaxNumValueData, uint32_t &ActualNumValueData, uint64_t &TotalC, bool GetNoICPValue=false)
 Extract the value profile data from Inst and returns them if Inst is annotated with value profile data.
 
MDNodellvm::getPGOFuncNameMetadata (const Function &F)
 Return the PGOFuncName meta data associated with a function.
 
void llvm::createPGOFuncNameMetadata (Function &F, StringRef PGOFuncName)
 Create the PGOFuncName meta data if PGOFuncName is different from function's raw name.
 
bool llvm::needsComdatForCounter (const GlobalObject &GV, const Module &M)
 Check if we can use Comdat for profile variables.
 
bool llvm::isIRPGOFlagSet (const Module *M)
 Check if INSTR_PROF_RAW_VERSION_VAR is defined.
 
bool llvm::canRenameComdatFunc (const Function &F, bool CheckAddressTaken=false)
 Check if we can safely rename this Comdat function.
 
void llvm::createProfileFileNameVar (Module &M, StringRef InstrProfileOutput)
 

Variables

static cl::opt< boolStaticFuncFullModulePrefix ("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< unsignedStaticFuncStripDirNamePrefix ("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< boolllvm::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."))
 
static ValueProfRecordClosure llvm::InstrProfRecordClosure
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instrprof"

Definition at line 61 of file InstrProf.cpp.

◆ INSTR_PROF_COMMON_API_IMPL

#define INSTR_PROF_COMMON_API_IMPL

Definition at line 1066 of file InstrProf.cpp.

◆ INSTR_PROF_SECT_ENTRY [1/3]

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

◆ INSTR_PROF_SECT_ENTRY [2/3]

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

◆ INSTR_PROF_SECT_ENTRY [3/3]

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

Function Documentation

◆ getInstrProfErrString()

static std::string getInstrProfErrString ( instrprof_error  Err,
const std::string &  ErrMsg = "" 
)
static

Definition at line 81 of file InstrProf.cpp.

References OS.

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

Variable Documentation

◆ 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