LLVM  4.0.0
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 <ModuleSummaryIndex.h>

Public Member Functions

gvsummary_iterator begin ()
 
const_gvsummary_iterator begin () const
 
gvsummary_iterator end ()
 
const_gvsummary_iterator end () const
 
size_t size () const
 
const GlobalValueSummaryListgetGlobalValueSummaryList (StringRef ValueName)
 Get the list of global value summary objects for a given value name. More...
 
const const_gvsummary_iterator findGlobalValueSummaryList (StringRef ValueName) const
 Get the list of global value summary objects for a given value name. More...
 
const const_gvsummary_iterator findGlobalValueSummaryList (GlobalValue::GUID ValueGUID) const
 Get the list of global value summary objects for a given value GUID. More...
 
void addGlobalValueSummary (StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
 Add a global value summary for a value of the given name. More...
 
void addGlobalValueSummary (GlobalValue::GUID ValueGUID, std::unique_ptr< GlobalValueSummary > Summary)
 Add a global value summary for a 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...
 
void mergeFrom (std::unique_ptr< ModuleSummaryIndex > Other, uint64_t NextModuleId)
 Add the given per-module index into this module index/summary, assigning it the given module ID. More...
 
ModulePathStringTableTy::iterator addModulePath (StringRef ModPath, uint64_t ModId, ModuleHash Hash=ModuleHash{{0}})
 Add a new module path with the given Hash, mapped to the given ModID, and return an iterator to the entry in the index. More...
 
bool hasExportedFunctions (const Module &M) const
 Check if the given Module has any functions available for exporting in the index. More...
 
void removeEmptySummaryEntries ()
 Remove entries in the GlobalValueMap that have empty summaries due to the eager nature of map entry creation during VST parsing. 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 361 of file ModuleSummaryIndex.h.

Member Function Documentation

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 403 of file ModuleSummaryIndex.h.

References llvm::GlobalValue::getGUID().

Referenced by computeAliasSummary(), computeFunctionSummary(), computeVariableSummary(), and mergeFrom().

void llvm::ModuleSummaryIndex::addGlobalValueSummary ( GlobalValue::GUID  ValueGUID,
std::unique_ptr< GlobalValueSummary Summary 
)
inline

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

Definition at line 410 of file ModuleSummaryIndex.h.

ModulePathStringTableTy::iterator llvm::ModuleSummaryIndex::addModulePath ( StringRef  ModPath,
uint64_t  ModId,
ModuleHash  Hash = ModuleHash{{0}} 
)
inline

Add a new module path with the given Hash, mapped to the given ModID, and return an iterator to the entry in the index.

Definition at line 496 of file ModuleSummaryIndex.h.

Referenced by mergeFrom().

gvsummary_iterator llvm::ModuleSummaryIndex::begin ( )
inline

Definition at line 379 of file ModuleSummaryIndex.h.

Referenced by removeEmptySummaryEntries().

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

Definition at line 380 of file ModuleSummaryIndex.h.

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

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

Definition at line 69 of file ModuleSummaryIndex.cpp.

Referenced by llvm::ComputeCrossModuleImportForModule().

void ModuleSummaryIndex::collectDefinedGVSummariesPerModule ( StringMap< GVSummaryMapTy > &  ModuleToDefinedGVSummaries) const
gvsummary_iterator llvm::ModuleSummaryIndex::end ( )
inline
const_gvsummary_iterator llvm::ModuleSummaryIndex::end ( ) const
inline

Definition at line 382 of file ModuleSummaryIndex.h.

const const_gvsummary_iterator llvm::ModuleSummaryIndex::findGlobalValueSummaryList ( StringRef  ValueName) const
inline

Get the list of global value summary objects for a given value name.

Definition at line 392 of file ModuleSummaryIndex.h.

References llvm::GlobalValue::getGUID().

Referenced by findSummaryInModule(), getGlobalValueSummary(), and setLiveRoot().

const const_gvsummary_iterator llvm::ModuleSummaryIndex::findGlobalValueSummaryList ( GlobalValue::GUID  ValueGUID) const
inline

Get the list of global value summary objects for a given value GUID.

Definition at line 398 of file ModuleSummaryIndex.h.

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 417 of file ModuleSummaryIndex.h.

References end(), llvm::find_if(), and findGlobalValueSummaryList().

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 479 of file ModuleSummaryIndex.h.

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

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 435 of file ModuleSummaryIndex.h.

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

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

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 98 of file ModuleSummaryIndex.cpp.

References assert(), end(), and findGlobalValueSummaryList().

const GlobalValueSummaryList& llvm::ModuleSummaryIndex::getGlobalValueSummaryList ( StringRef  ValueName)
inline

Get the list of global value summary objects for a given value name.

Definition at line 386 of file ModuleSummaryIndex.h.

References llvm::GlobalValue::getGUID().

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

Get the module SHA1 hash recorded for the given module path.

Definition at line 464 of file ModuleSummaryIndex.h.

References assert().

Referenced by computeCacheKey().

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

Get the module ID recorded for the given module path.

Definition at line 459 of file ModuleSummaryIndex.h.

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 488 of file ModuleSummaryIndex.h.

References llvm::StringRef::split().

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 506 of file ModuleSummaryIndex.h.

References llvm::Module::getModuleIdentifier().

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

void ModuleSummaryIndex::mergeFrom ( std::unique_ptr< ModuleSummaryIndex Other,
uint64_t  NextModuleId 
)

Add the given per-module index into this module index/summary, assigning it the given module ID.

Each module merged in should have a unique ID, necessary for consistent renaming of promoted static (local) variables.

Definition at line 21 of file ModuleSummaryIndex.cpp.

References addGlobalValueSummary(), addModulePath(), assert(), llvm::StringRef::begin(), and List.

Referenced by llvm::ThinLTOCodeGenerator::linkCombinedIndex().

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

Table of modules, containing hash and id.

Definition at line 454 of file ModuleSummaryIndex.h.

void ModuleSummaryIndex::removeEmptySummaryEntries ( )

Remove entries in the GlobalValueMap that have empty summaries due to the eager nature of map entry creation during VST parsing.

These would also be suppressed during combined index generation in mergeFrom(), but if there was only one module or this was the first module we might not invoke mergeFrom.

Definition at line 55 of file ModuleSummaryIndex.cpp.

References assert(), begin(), end(), and MI.

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

Definition at line 383 of file ModuleSummaryIndex.h.


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