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

Class to hold module path string table and global value map, and encapsulate methods for operating on them. More...

#include "llvm/IR/ModuleSummaryIndex.h"

Public Types

typedef ModulePathStringTableTy::value_type ModuleInfo
 

Public Member Functions

gvsummary_iterator begin ()
 
const_gvsummary_iterator begin () const
 
gvsummary_iterator end ()
 
const_gvsummary_iterator end () const
 
size_t size () const
 
bool withGlobalValueDeadStripping () const
 
void setWithGlobalValueDeadStripping ()
 
bool isGlobalValueLive (const GlobalValueSummary *GVS) const
 
bool isGUIDLive (GlobalValue::GUID GUID) const
 
ValueInfo getValueInfo (GlobalValue::GUID GUID) const
 Return a ValueInfo for GUID if it exists, otherwise return ValueInfo(). More...
 
ValueInfo getOrInsertValueInfo (GlobalValue::GUID GUID)
 Return a ValueInfo for GUID. More...
 
ValueInfo getOrInsertValueInfo (const GlobalValue *GV)
 Return a ValueInfo for GV and mark it as belonging to GV. More...
 
GlobalValue::GUID getGUIDFromOriginalID (GlobalValue::GUID OriginalID) const
 Return the GUID for OriginalId in the OidGuidMap. More...
 
std::set< std::string > & cfiFunctionDefs ()
 
const std::set< std::string > & cfiFunctionDefs () const
 
std::set< std::string > & cfiFunctionDecls ()
 
const std::set< std::string > & cfiFunctionDecls () const
 
void addGlobalValueSummary (StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
 Add a global value summary for a value of the given name. More...
 
void addGlobalValueSummary (ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
 Add a global value summary for the given ValueInfo. More...
 
void addOriginalName (GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
 Add an original name for the value of the given GUID. More...
 
GlobalValueSummaryfindSummaryInModule (GlobalValue::GUID ValueGUID, StringRef ModuleId) const
 Find the summary for global GUID in module ModuleId, or nullptr if not found. More...
 
GlobalValueSummarygetGlobalValueSummary (const GlobalValue &GV, bool PerModuleIndex=true) const
 Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex. More...
 
GlobalValueSummarygetGlobalValueSummary (GlobalValue::GUID ValueGUID, bool PerModuleIndex=true) const
 Returns the first GlobalValueSummary for ValueGUID, asserting that there is only one if PerModuleIndex. More...
 
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths () const
 Table of modules, containing module hash and id. More...
 
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths ()
 Table of modules, containing hash and id. More...
 
uint64_t getModuleId (const StringRef ModPath) const
 Get the module ID recorded for the given module path. More...
 
const ModuleHashgetModuleHash (const StringRef ModPath) const
 Get the module SHA1 hash recorded for the given module path. More...
 
ModuleInfoaddModule (StringRef ModPath, uint64_t ModId, ModuleHash Hash=ModuleHash{{0}})
 Add a new module with the given Hash, mapped to the given ModID, and return a reference to the module. More...
 
bool hasExportedFunctions (const Module &M) const
 Check if the given Module has any functions available for exporting in the index. More...
 
const std::map< std::string, TypeIdSummary > & typeIds () const
 
TypeIdSummarygetOrInsertTypeIdSummary (StringRef TypeId)
 This accessor should only be used when exporting because it can mutate the map. More...
 
const TypeIdSummarygetTypeIdSummary (StringRef TypeId) const
 This returns either a pointer to the type id summary (if present in the summary map) or null (if not present). More...
 
void collectDefinedFunctionsForModule (StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
 Collect for the given module the list of function it defines (GUID -> Summary). More...
 
void collectDefinedGVSummariesPerModule (StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries) const
 Collect for each module the list of Summaries it defines (GUID -> Summary). More...
 

Static Public Member Functions

static std::string getGlobalNameForLocal (StringRef Name, ModuleHash ModHash)
 Convenience method for creating a promoted global name for the given value name of a local, and its original module's ID. More...
 
static StringRef getOriginalNameBeforePromote (StringRef Name)
 Helper to obtain the unpromoted name for a global value (or the original name if not promoted). More...
 

Detailed Description

Class to hold module path string table and global value map, and encapsulate methods for operating on them.

Definition at line 599 of file ModuleSummaryIndex.h.

Member Typedef Documentation

◆ ModuleInfo

Definition at line 782 of file ModuleSummaryIndex.h.

Member Function Documentation

◆ addGlobalValueSummary() [1/2]

void llvm::ModuleSummaryIndex::addGlobalValueSummary ( StringRef  ValueName,
std::unique_ptr< GlobalValueSummary Summary 
)
inline

Add a global value summary for a value of the given name.

Definition at line 683 of file ModuleSummaryIndex.h.

References llvm::GlobalValue::getGUID().

Referenced by llvm::buildModuleSummaryIndex(), computeAliasSummary(), computeFunctionSummary(), computeVariableSummary(), and readWideAPInt().

◆ addGlobalValueSummary() [2/2]

void llvm::ModuleSummaryIndex::addGlobalValueSummary ( ValueInfo  VI,
std::unique_ptr< GlobalValueSummary Summary 
)
inline

Add a global value summary for the given ValueInfo.

Definition at line 690 of file ModuleSummaryIndex.h.

References llvm::ValueInfo::getGUID(), llvm::ValueInfo::Ref, and second.

◆ addModule()

ModuleInfo* llvm::ModuleSummaryIndex::addModule ( StringRef  ModPath,
uint64_t  ModId,
ModuleHash  Hash = ModuleHash{{0}} 
)
inline

Add a new module with the given Hash, mapped to the given ModID, and return a reference to the module.

Definition at line 786 of file ModuleSummaryIndex.h.

References first, and llvm::StringMap< ValueTy, AllocatorTy >::insert().

Referenced by readWideAPInt().

◆ addOriginalName()

void llvm::ModuleSummaryIndex::addOriginalName ( GlobalValue::GUID  ValueGUID,
GlobalValue::GUID  OrigGUID 
)
inline

Add an original name for the value of the given GUID.

Definition at line 700 of file ModuleSummaryIndex.h.

Referenced by readWideAPInt().

◆ begin() [1/2]

gvsummary_iterator llvm::ModuleSummaryIndex::begin ( )
inline

Definition at line 634 of file ModuleSummaryIndex.h.

◆ begin() [2/2]

const_gvsummary_iterator llvm::ModuleSummaryIndex::begin ( ) const
inline

Definition at line 635 of file ModuleSummaryIndex.h.

◆ cfiFunctionDecls() [1/2]

std::set<std::string>& llvm::ModuleSummaryIndex::cfiFunctionDecls ( )
inline

◆ cfiFunctionDecls() [2/2]

const std::set<std::string>& llvm::ModuleSummaryIndex::cfiFunctionDecls ( ) const
inline

Definition at line 680 of file ModuleSummaryIndex.h.

◆ cfiFunctionDefs() [1/2]

std::set<std::string>& llvm::ModuleSummaryIndex::cfiFunctionDefs ( )
inline

◆ cfiFunctionDefs() [2/2]

const std::set<std::string>& llvm::ModuleSummaryIndex::cfiFunctionDefs ( ) const
inline

Definition at line 677 of file ModuleSummaryIndex.h.

◆ collectDefinedFunctionsForModule()

void ModuleSummaryIndex::collectDefinedFunctionsForModule ( StringRef  ModulePath,
GVSummaryMapTy GVSummaryMap 
) const

Collect for the given module the list of function it defines (GUID -> Summary).

Definition at line 21 of file ModuleSummaryIndex.cpp.

Referenced by llvm::ComputeCrossModuleImportForModule().

◆ collectDefinedGVSummariesPerModule()

void ModuleSummaryIndex::collectDefinedGVSummariesPerModule ( StringMap< GVSummaryMapTy > &  ModuleToDefinedGVSummaries) const

◆ end() [1/2]

gvsummary_iterator llvm::ModuleSummaryIndex::end ( )
inline

Definition at line 636 of file ModuleSummaryIndex.h.

◆ end() [2/2]

const_gvsummary_iterator llvm::ModuleSummaryIndex::end ( ) const
inline

Definition at line 637 of file ModuleSummaryIndex.h.

◆ findSummaryInModule()

GlobalValueSummary* llvm::ModuleSummaryIndex::findSummaryInModule ( GlobalValue::GUID  ValueGUID,
StringRef  ModuleId 
) const
inline

Find the summary for global GUID in module ModuleId, or nullptr if not found.

Definition at line 712 of file ModuleSummaryIndex.h.

References llvm::find_if().

Referenced by computeCacheKey(), llvm::FunctionImportGlobalProcessing::doImportAsDefinition(), and readWideAPInt().

◆ getGlobalNameForLocal()

static std::string llvm::ModuleSummaryIndex::getGlobalNameForLocal ( StringRef  Name,
ModuleHash  ModHash 
)
inlinestatic

Convenience method for creating a promoted global name for the given value name of a local, and its original module's ID.

Definition at line 767 of file ModuleSummaryIndex.h.

References llvm::SmallString< InternalLen >::str(), and llvm::utostr().

Referenced by llvm::FunctionImportGlobalProcessing::doImportAsDefinition().

◆ getGlobalValueSummary() [1/2]

GlobalValueSummary* llvm::ModuleSummaryIndex::getGlobalValueSummary ( const GlobalValue GV,
bool  PerModuleIndex = true 
) const
inline

Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.

Definition at line 730 of file ModuleSummaryIndex.h.

References assert(), llvm::GlobalValue::getGUID(), llvm::Value::getName(), and llvm::Value::hasName().

Referenced by llvm::buildModuleSummaryIndex(), and computeAliasSummary().

◆ getGlobalValueSummary() [2/2]

GlobalValueSummary * ModuleSummaryIndex::getGlobalValueSummary ( GlobalValue::GUID  ValueGUID,
bool  PerModuleIndex = true 
) const

Returns the first GlobalValueSummary for ValueGUID, asserting that there is only one if PerModuleIndex.

Definition at line 50 of file ModuleSummaryIndex.cpp.

References assert(), getValueInfo(), and VI.

◆ getGUIDFromOriginalID()

GlobalValue::GUID llvm::ModuleSummaryIndex::getGUIDFromOriginalID ( GlobalValue::GUID  OriginalID) const
inline

Return the GUID for OriginalId in the OidGuidMap.

Definition at line 671 of file ModuleSummaryIndex.h.

References I.

Referenced by updateValueInfoForIndirectCalls().

◆ getModuleHash()

const ModuleHash& llvm::ModuleSummaryIndex::getModuleHash ( const StringRef  ModPath) const
inline

◆ getModuleId()

uint64_t llvm::ModuleSummaryIndex::getModuleId ( const StringRef  ModPath) const
inline

Get the module ID recorded for the given module path.

Definition at line 754 of file ModuleSummaryIndex.h.

References llvm::StringMap< ValueTy, AllocatorTy >::lookup().

◆ getOriginalNameBeforePromote()

static StringRef llvm::ModuleSummaryIndex::getOriginalNameBeforePromote ( StringRef  Name)
inlinestatic

Helper to obtain the unpromoted name for a global value (or the original name if not promoted).

Definition at line 777 of file ModuleSummaryIndex.h.

References llvm::StringRef::split().

Referenced by llvm::thinLTOInternalizeModule().

◆ getOrInsertTypeIdSummary()

TypeIdSummary& llvm::ModuleSummaryIndex::getOrInsertTypeIdSummary ( StringRef  TypeId)
inline

This accessor should only be used when exporting because it can mutate the map.

Definition at line 804 of file ModuleSummaryIndex.h.

◆ getOrInsertValueInfo() [1/2]

ValueInfo llvm::ModuleSummaryIndex::getOrInsertValueInfo ( GlobalValue::GUID  GUID)
inline

Return a ValueInfo for GUID.

Definition at line 659 of file ModuleSummaryIndex.h.

Referenced by computeFunctionSummary(), findRefEdges(), and readWideAPInt().

◆ getOrInsertValueInfo() [2/2]

ValueInfo llvm::ModuleSummaryIndex::getOrInsertValueInfo ( const GlobalValue GV)
inline

Return a ValueInfo for GV and mark it as belonging to GV.

Definition at line 664 of file ModuleSummaryIndex.h.

References llvm::GlobalValue::getGUID().

◆ getTypeIdSummary()

const TypeIdSummary* llvm::ModuleSummaryIndex::getTypeIdSummary ( StringRef  TypeId) const
inline

This returns either a pointer to the type id summary (if present in the summary map) or null (if not present).

This may be used when importing.

Definition at line 810 of file ModuleSummaryIndex.h.

References I.

◆ getValueInfo()

ValueInfo llvm::ModuleSummaryIndex::getValueInfo ( GlobalValue::GUID  GUID) const
inline

Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().

Definition at line 653 of file ModuleSummaryIndex.h.

References I.

Referenced by llvm::computeDeadSymbols(), llvm::FunctionImportGlobalProcessing::doImportAsDefinition(), getGlobalValueSummary(), isGUIDLive(), setLiveRoot(), and updateValueInfoForIndirectCalls().

◆ hasExportedFunctions()

bool llvm::ModuleSummaryIndex::hasExportedFunctions ( const Module M) const
inline

Check if the given Module has any functions available for exporting in the index.

We consider any module present in the ModulePathStringTable to have exported functions.

Definition at line 794 of file ModuleSummaryIndex.h.

References llvm::StringMap< ValueTy, AllocatorTy >::count(), and llvm::Module::getModuleIdentifier().

Referenced by llvm::FunctionImportGlobalProcessing::FunctionImportGlobalProcessing().

◆ isGlobalValueLive()

bool llvm::ModuleSummaryIndex::isGlobalValueLive ( const GlobalValueSummary GVS) const
inline

Definition at line 647 of file ModuleSummaryIndex.h.

Referenced by ComputeImportForModule(), and isGUIDLive().

◆ isGUIDLive()

bool ModuleSummaryIndex::isGUIDLive ( GlobalValue::GUID  GUID) const

Definition at line 60 of file ModuleSummaryIndex.cpp.

References getValueInfo(), I, isGlobalValueLive(), and VI.

◆ modulePaths() [1/2]

const StringMap<std::pair<uint64_t, ModuleHash> >& llvm::ModuleSummaryIndex::modulePaths ( ) const
inline

◆ modulePaths() [2/2]

StringMap<std::pair<uint64_t, ModuleHash> >& llvm::ModuleSummaryIndex::modulePaths ( )
inline

Table of modules, containing hash and id.

Definition at line 749 of file ModuleSummaryIndex.h.

◆ setWithGlobalValueDeadStripping()

void llvm::ModuleSummaryIndex::setWithGlobalValueDeadStripping ( )
inline

Definition at line 643 of file ModuleSummaryIndex.h.

◆ size()

size_t llvm::ModuleSummaryIndex::size ( ) const
inline

Definition at line 638 of file ModuleSummaryIndex.h.

◆ typeIds()

const std::map<std::string, TypeIdSummary>& llvm::ModuleSummaryIndex::typeIds ( ) const
inline

Definition at line 798 of file ModuleSummaryIndex.h.

Referenced by llvm::lto::ThinBackendProc::~ThinBackendProc().

◆ withGlobalValueDeadStripping()

bool llvm::ModuleSummaryIndex::withGlobalValueDeadStripping ( ) const
inline

Definition at line 640 of file ModuleSummaryIndex.h.

Referenced by llvm::computeDeadSymbols().


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