LLVM 18.0.0git
|
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the function. More...
#include "llvm/ProfileData/InstrProf.h"
Public Types | |
using | AddrHashMap = std::vector< std::pair< uint64_t, uint64_t > > |
Public Member Functions | |
InstrProfSymtab ()=default | |
Error | create (object::SectionRef &Section) |
Create InstrProfSymtab from an object file section which contains function PGO names. | |
Error | create (StringRef D, uint64_t BaseAddr) |
This interface is used by reader of CoverageMapping test format. | |
Error | create (StringRef NameStrings) |
NameStrings is a string composed of one of more sub-strings encoded in the format described in collectPGOFuncNameStrings . | |
Error | create (Module &M, bool InLTO=false) |
A wrapper interface to populate the PGO symtab with functions decls from module M . | |
template<typename NameIterRange > | |
Error | create (const NameIterRange &IterRange) |
Create InstrProfSymtab from a set of names iteratable from IterRange . | |
Error | addFuncName (StringRef FuncName) |
Update the symtab by adding FuncName to the table. | |
void | mapAddress (uint64_t Addr, uint64_t MD5Val) |
Map a function address to its name's MD5 hash. | |
uint64_t | getFunctionHashFromAddress (uint64_t Address) |
Return a function's hash, or 0, if the function isn't in this SymTab. | |
StringRef | getFuncName (uint64_t FuncNameAddress, size_t NameSize) |
Return function's PGO name from the function name's symbol address in the object file. | |
StringRef | getFuncName (uint64_t FuncMD5Hash) |
Return function's PGO name from the name's md5 hash value. | |
StringRef | getFuncNameOrExternalSymbol (uint64_t FuncMD5Hash) |
Just like getFuncName, except that it will return a non-empty StringRef if the function is external to this symbol table. | |
Function * | getFunction (uint64_t FuncMD5Hash) |
Return function from the name's md5 hash. Return nullptr if not found. | |
StringRef | getNameData () const |
Return the name section data. | |
void | dumpNames (raw_ostream &OS) const |
Dump the symbols in this table. | |
Static Public Member Functions | |
static bool | isExternalSymbol (const StringRef &Symbol) |
True if Symbol is the value used to represent external symbols. | |
A symbol table used for function PGO name look-up with keys (such as pointers, md5hash values) to the function.
A function's PGO name or name's md5hash are used in retrieving the profile data of the function. See getPGOFuncName()
method for details on how PGO name is formed.
Definition at line 427 of file InstrProf.h.
using llvm::InstrProfSymtab::AddrHashMap = std::vector<std::pair<uint64_t, uint64_t> > |
Definition at line 429 of file InstrProf.h.
|
default |
Update the symtab by adding FuncName
to the table.
This interface is used by the raw and text profile readers.
Definition at line 490 of file InstrProf.h.
References llvm::IndexedInstrProf::ComputeHash(), llvm::StringRef::empty(), llvm::StringSet< AllocatorTy >::insert(), llvm::malformed, and llvm::Error::success().
Referenced by create(), llvm::readPGOFuncNameStrings(), and llvm::InstrProfWriter::writeText().
Error llvm::InstrProfSymtab::create | ( | const NameIterRange & | IterRange | ) |
Create InstrProfSymtab from a set of names iteratable from IterRange
.
This interface is used by IndexedProfReader.
Definition at line 552 of file InstrProf.h.
References addFuncName(), E, Name, and llvm::Error::success().
A wrapper interface to populate the PGO symtab with functions decls from module M
.
This interface is used by transformation passes such as indirect function call promotion. Variable InLTO
indicates if this is called from LTO optimization passes.
Definition at line 430 of file InstrProf.cpp.
References E, F, llvm::getIRPGOFuncName(), llvm::getPGOFuncName(), and llvm::Error::success().
Error InstrProfSymtab::create | ( | object::SectionRef & | Section | ) |
Create InstrProfSymtab from an object file section which contains function PGO names.
When section may contain raw string data or string data in compressed form. This method only initialize the symtab with reference to the data and the section base address. The decompression will be delayed until before it is used. See also create(StringRef)
method.
Definition at line 461 of file CoverageMappingReader.cpp.
References llvm::Address, llvm::Data, llvm::object::ObjectFile::isRelocatableObject(), llvm::Error::success(), and llvm::Expected< T >::takeError().
Referenced by getProfileNamesFromDebugInfo(), loadBinaryFormat(), loadTestingFormat(), llvm::InstrProfReaderIndex< HashTableImpl >::populateSymtab(), promoteIndirectCalls(), and runCGProfilePass().
This interface is used by reader of CoverageMapping test format.
Definition at line 541 of file InstrProf.h.
References D, and llvm::Error::success().
NameStrings
is a string composed of one of more sub-strings encoded in the format described in collectPGOFuncNameStrings
.
This method is a wrapper to readPGOFuncNameStrings
method.
Definition at line 547 of file InstrProf.h.
References llvm::readPGOFuncNameStrings().
void llvm::InstrProfSymtab::dumpNames | ( | raw_ostream & | OS | ) | const |
Dump the symbols in this table.
Definition at line 493 of file InstrProf.cpp.
References llvm::StringMap< ValueTy, AllocatorTy >::keys(), OS, and llvm::sort().
Return function's PGO name from the name's md5 hash value.
If not found, return an empty string.
Definition at line 579 of file InstrProf.h.
References LHS, llvm::lower_bound(), and RHS.
Return function's PGO name from the function name's symbol address in the object file.
If an error occurs, return an empty string.
Definition at line 477 of file CoverageMappingReader.cpp.
References llvm::Address, llvm::Data, llvm::Offset, and Size.
Referenced by llvm::coverage::CovMapFunctionRecordV1< IntPtrT >::getFuncName(), getFuncNameOrExternalSymbol(), llvm::coverage::accessors::getFuncNameViaRef(), and llvm::InstrProfWriter::writeTextTemporalProfTraceData().
Just like getFuncName, except that it will return a non-empty StringRef if the function is external to this symbol table.
All such cases will be represented using the same StringRef value.
Definition at line 572 of file InstrProf.h.
References llvm::StringRef::empty(), and getFuncName().
Referenced by llvm::InstrProfWriter::writeRecordInText().
Return function from the name's md5 hash. Return nullptr if not found.
Definition at line 589 of file InstrProf.h.
References LHS, llvm::lower_bound(), and RHS.
Referenced by runCGProfilePass().
Return a function's hash, or 0, if the function isn't in this SymTab.
Definition at line 479 of file InstrProf.cpp.
References A, and llvm::partition_point().
|
inline |
True if Symbol is the value used to represent external symbols.
Definition at line 527 of file InstrProf.h.
Map a function address to its name's MD5 hash.
This interface is only used by the raw profiler reader.
Definition at line 505 of file InstrProf.h.
References Addr.