LLVM  6.0.0svn
Public Types | Public Member Functions | List of all members
llvm::InstrProfSymtab Class Reference

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. More...
 
Error create (StringRef D, uint64_t BaseAddr)
 This interface is used by reader of CoverageMapping test format. More...
 
Error create (StringRef NameStrings)
 NameStrings is a string composed of one of more sub-strings encoded in the format described in collectPGOFuncNameStrings. More...
 
Error create (Module &M, bool InLTO=false)
 A wrapper interface to populate the PGO symtab with functions decls from module M. More...
 
template<typename NameIterRange >
Error create (const NameIterRange &IterRange)
 Create InstrProfSymtab from a set of names iteratable from IterRange. More...
 
void finalizeSymtab ()
 
Error addFuncName (StringRef FuncName)
 Update the symtab by adding FuncName to the table. More...
 
void mapAddress (uint64_t Addr, uint64_t MD5Val)
 Map a function address to its name's MD5 hash. More...
 
AddrHashMapgetAddrHashMap ()
 
StringRef getFuncName (uint64_t FuncNameAddress, size_t NameSize)
 Return function's PGO name from the function name's symbol address in the object file. More...
 
StringRef getFuncName (uint64_t FuncMD5Hash)
 Return function's PGO name from the name's md5 hash value. More...
 
FunctiongetFunction (uint64_t FuncMD5Hash)
 Return function from the name's md5 hash. Return nullptr if not found. More...
 
StringRef getOrigFuncName (uint64_t FuncMD5Hash)
 Return the function's original assembly name by stripping off the prefix attached (to symbols with priviate linkage). More...
 
StringRef getNameData () const
 Return the name section data. More...
 

Detailed Description

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 411 of file InstrProf.h.

Member Typedef Documentation

◆ AddrHashMap

using llvm::InstrProfSymtab::AddrHashMap = std::vector<std::pair<uint64_t, uint64_t> >

Definition at line 413 of file InstrProf.h.

Constructor & Destructor Documentation

◆ InstrProfSymtab()

llvm::InstrProfSymtab::InstrProfSymtab ( )
default

Member Function Documentation

◆ addFuncName()

Error llvm::InstrProfSymtab::addFuncName ( StringRef  FuncName)
inline

Update the symtab by adding FuncName to the table.

This interface is used by the raw and text profile readers.

Definition at line 467 of file InstrProf.h.

References llvm::IndexedInstrProf::ComputeHash(), llvm::StringRef::empty(), llvm::MipsISD::Ins, llvm::StringSet< AllocatorTy >::insert(), llvm::malformed, and llvm::Error::success().

Referenced by llvm::readPGOFuncNameStrings(), and llvm::InstrProfWriter::writeText().

◆ create() [1/5]

Error llvm::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.

Referenced by llvm::coverage::RawCoverageMappingDummyChecker::isDummy(), loadBinaryFormat(), loadTestingFormat(), llvm::InstrProfReaderIndex< HashTableImpl >::populateSymtab(), promoteIndirectCalls(), and llvm::RawInstrProfReader< IntPtrT >::readHeader().

◆ create() [2/5]

Error llvm::InstrProfSymtab::create ( StringRef  D,
uint64_t  BaseAddr 
)
inline

This interface is used by reader of CoverageMapping test format.

Definition at line 506 of file InstrProf.h.

References llvm::dwarf::syntax::Address, D, llvm::Data, and llvm::Error::success().

◆ create() [3/5]

Error llvm::InstrProfSymtab::create ( StringRef  NameStrings)
inline

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 512 of file InstrProf.h.

References llvm::readPGOFuncNameStrings().

◆ create() [4/5]

Error llvm::InstrProfSymtab::create ( Module M,
bool  InLTO = false 
)

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 335 of file InstrProf.cpp.

References E, F(), llvm::GlobalValue::getGUID(), llvm::getPGOFuncName(), and llvm::Error::success().

◆ create() [5/5]

template<typename NameIterRange >
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 517 of file InstrProf.h.

References E, and llvm::Error::success().

◆ finalizeSymtab()

void llvm::InstrProfSymtab::finalizeSymtab ( )
inline

◆ getAddrHashMap()

AddrHashMap& llvm::InstrProfSymtab::getAddrHashMap ( )
inline

Definition at line 483 of file InstrProf.h.

References llvm::COFF::NameSize.

Referenced by llvm::RawInstrProfReader< IntPtrT >::readHeader().

◆ getFuncName() [1/2]

StringRef InstrProfSymtab::getFuncName ( uint64_t  FuncNameAddress,
size_t  NameSize 
)

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 365 of file CoverageMappingReader.cpp.

References llvm::dwarf::syntax::Address, and llvm::Data.

Referenced by llvm::coverage::CovMapFunctionRecordV1< IntPtrT >::getFuncName(), llvm::coverage::CovMapFunctionRecord::getFuncName(), llvm::RawInstrProfReader< IntPtrT >::getSymtab(), and llvm::InstrProfWriter::writeRecordInText().

◆ getFuncName() [2/2]

StringRef llvm::InstrProfSymtab::getFuncName ( uint64_t  FuncMD5Hash)
inline

Return function's PGO name from the name's md5 hash value.

If not found, return an empty string.

Definition at line 534 of file InstrProf.h.

References llvm::lower_bound().

◆ getFunction()

Function * llvm::InstrProfSymtab::getFunction ( uint64_t  FuncMD5Hash)
inline

Return function from the name's md5 hash. Return nullptr if not found.

Definition at line 544 of file InstrProf.h.

References llvm::lower_bound().

◆ getNameData()

StringRef llvm::InstrProfSymtab::getNameData ( ) const
inline

Return the name section data.

Definition at line 503 of file InstrProf.h.

References llvm::Data.

◆ getOrigFuncName()

StringRef llvm::InstrProfSymtab::getOrigFuncName ( uint64_t  FuncMD5Hash)
inline

Return the function's original assembly name by stripping off the prefix attached (to symbols with priviate linkage).

For global functions, it returns the same string as getFuncName.

Definition at line 556 of file InstrProf.h.

References llvm::StringRef::drop_front(), llvm::StringRef::find_first_of(), and llvm::StringRef::npos.

◆ mapAddress()

void llvm::InstrProfSymtab::mapAddress ( uint64_t  Addr,
uint64_t  MD5Val 
)
inline

Map a function address to its name's MD5 hash.

This interface is only used by the raw profiler reader.

Definition at line 479 of file InstrProf.h.

Referenced by llvm::RawInstrProfReader< IntPtrT >::readHeader().


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