LLVM 17.0.0git
|
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 | |
ModuleSummaryIndex (bool HaveGVs, bool EnableSplitLTOUnit=false) | |
bool | haveGVs () const |
uint64_t | getFlags () const |
void | setFlags (uint64_t Flags) |
uint64_t | getBlockCount () const |
void | addBlockCount (uint64_t C) |
void | setBlockCount (uint64_t C) |
gvsummary_iterator | begin () |
const_gvsummary_iterator | begin () const |
gvsummary_iterator | end () |
const_gvsummary_iterator | end () const |
size_t | size () const |
const std::vector< uint64_t > & | stackIds () const |
unsigned | addOrGetStackIdIndex (uint64_t StackId) |
uint64_t | getStackIdAtIndex (unsigned Index) const |
void | releaseTemporaryMemory () |
FunctionSummary | calculateCallGraphRoot () |
bool | withGlobalValueDeadStripping () const |
void | setWithGlobalValueDeadStripping () |
bool | withAttributePropagation () const |
void | setWithAttributePropagation () |
bool | withDSOLocalPropagation () const |
void | setWithDSOLocalPropagation () |
bool | withWholeProgramVisibility () const |
void | setWithWholeProgramVisibility () |
bool | isReadOnly (const GlobalVarSummary *GVS) const |
bool | isWriteOnly (const GlobalVarSummary *GVS) const |
bool | hasSyntheticEntryCounts () const |
void | setHasSyntheticEntryCounts () |
bool | skipModuleByDistributedBackend () const |
void | setSkipModuleByDistributedBackend () |
bool | enableSplitLTOUnit () const |
void | setEnableSplitLTOUnit () |
bool | partiallySplitLTOUnits () const |
void | setPartiallySplitLTOUnits () |
bool | hasParamAccess () const |
bool | isGlobalValueLive (const GlobalValueSummary *GVS) const |
bool | isGUIDLive (GlobalValue::GUID GUID) const |
ValueInfo | getValueInfo (const GlobalValueSummaryMapTy::value_type &R) const |
Return a ValueInfo for the index value_type (convenient when iterating index). | |
ValueInfo | getValueInfo (GlobalValue::GUID GUID) const |
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo(). | |
ValueInfo | getOrInsertValueInfo (GlobalValue::GUID GUID) |
Return a ValueInfo for GUID . | |
StringRef | saveString (StringRef String) |
ValueInfo | getOrInsertValueInfo (GlobalValue::GUID GUID, StringRef Name) |
Return a ValueInfo for GUID setting value Name . | |
ValueInfo | getOrInsertValueInfo (const GlobalValue *GV) |
Return a ValueInfo for GV and mark it as belonging to GV. | |
GlobalValue::GUID | getGUIDFromOriginalID (GlobalValue::GUID OriginalID) const |
Return the GUID for OriginalId in the OidGuidMap. | |
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 (const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary) |
Add a global value summary for a value. | |
void | addGlobalValueSummary (StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary) |
Add a global value summary for a value of the given name. | |
void | addGlobalValueSummary (ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary) |
Add a global value summary for the given ValueInfo. | |
void | addOriginalName (GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID) |
Add an original name for the value of the given GUID. | |
GlobalValueSummary * | findSummaryInModule (ValueInfo VI, StringRef ModuleId) const |
Find the summary for ValueInfo VI in module ModuleId , or nullptr if not found. | |
GlobalValueSummary * | findSummaryInModule (GlobalValue::GUID ValueGUID, StringRef ModuleId) const |
Find the summary for global GUID in module ModuleId , or nullptr if not found. | |
GlobalValueSummary * | getGlobalValueSummary (const GlobalValue &GV, bool PerModuleIndex=true) const |
Returns the first GlobalValueSummary for GV , asserting that there is only one if PerModuleIndex . | |
GlobalValueSummary * | getGlobalValueSummary (GlobalValue::GUID ValueGUID, bool PerModuleIndex=true) const |
Returns the first GlobalValueSummary for ValueGUID , asserting that there is only one if PerModuleIndex . | |
const StringMap< std::pair< uint64_t, ModuleHash > > & | modulePaths () const |
Table of modules, containing module hash and id. | |
StringMap< std::pair< uint64_t, ModuleHash > > & | modulePaths () |
Table of modules, containing hash and id. | |
uint64_t | getModuleId (const StringRef ModPath) const |
Get the module ID recorded for the given module path. | |
const ModuleHash & | getModuleHash (const StringRef ModPath) const |
Get the module SHA1 hash recorded for the given module path. | |
ModuleInfo * | addModule (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. | |
ModuleInfo * | getModule (StringRef ModPath) |
Return module entry for module with the given ModPath . | |
bool | hasExportedFunctions (const Module &M) const |
Check if the given Module has any functions available for exporting in the index. | |
const TypeIdSummaryMapTy & | typeIds () const |
TypeIdSummary & | getOrInsertTypeIdSummary (StringRef TypeId) |
Return an existing or new TypeIdSummary entry for TypeId . | |
const TypeIdSummary * | getTypeIdSummary (StringRef TypeId) const |
This returns either a pointer to the type id summary (if present in the summary map) or null (if not present). | |
TypeIdSummary * | getTypeIdSummary (StringRef TypeId) |
const auto & | typeIdCompatibleVtableMap () const |
TypeIdCompatibleVtableInfo & | getOrInsertTypeIdCompatibleVtableSummary (StringRef TypeId) |
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId . | |
std::optional< TypeIdCompatibleVtableInfo > | getTypeIdCompatibleVtableSummary (StringRef TypeId) const |
For the given TypeId , this returns the TypeIdCompatibleVtableMap entry if present in the summary map. | |
void | collectDefinedFunctionsForModule (StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const |
Collect for the given module the list of functions it defines (GUID -> Summary). | |
template<class Map > | |
void | collectDefinedGVSummariesPerModule (Map &ModuleToDefinedGVSummaries) const |
Collect for each module the list of Summaries it defines (GUID -> Summary). | |
void | print (raw_ostream &OS, bool IsForDebug=false) const |
Print to an output stream. | |
void | dump () const |
Dump to stderr (for debugging). | |
void | exportToDot (raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const |
Export summary to dot file for GraphViz. | |
void | dumpSCCs (raw_ostream &OS) |
Print out strongly connected components for debugging. | |
void | propagateAttributes (const DenseSet< GlobalValue::GUID > &PreservedSymbols) |
Do the access attribute and DSOLocal propagation in combined index. | |
bool | canImportGlobalVar (GlobalValueSummary *S, bool AnalyzeRefs) const |
Checks if we can import global variable from another module. | |
Static Public Member Functions | |
static constexpr const char * | getRegularLTOModuleName () |
static void | discoverNodes (ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent) |
Convenience function for doing a DFS on a ValueInfo. | |
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. | |
static std::string | getGlobalNameForLocal (StringRef Name, StringRef Suffix) |
static StringRef | getOriginalNameBeforePromote (StringRef Name) |
Helper to obtain the unpromoted name for a global value (or the original name if not promoted). | |
Static Public Attributes | |
static constexpr uint64_t | BitcodeSummaryVersion = 9 |
Class to hold module path string table and global value map, and encapsulate methods for operating on them.
Definition at line 1249 of file ModuleSummaryIndex.h.
Definition at line 1686 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1349 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1371 of file ModuleSummaryIndex.h.
References llvm::CallingConv::C.
|
inline |
Add a global value summary for a value.
Definition at line 1567 of file ModuleSummaryIndex.h.
References addGlobalValueSummary(), and getOrInsertValueInfo().
Referenced by addGlobalValueSummary().
|
inline |
Add a global value summary for a value of the given name.
Definition at line 1573 of file ModuleSummaryIndex.h.
References addGlobalValueSummary(), llvm::GlobalValue::getGUID(), and getOrInsertValueInfo().
|
inline |
Add a global value summary for the given ValueInfo.
Definition at line 1580 of file ModuleSummaryIndex.h.
References addOriginalName(), and VI.
|
inline |
Add a new module with the given Hash
, mapped to the given ModID
, and return a reference to the module.
Definition at line 1690 of file ModuleSummaryIndex.h.
Definition at line 1382 of file ModuleSummaryIndex.h.
|
inline |
Add an original name for the value of the given GUID.
Definition at line 1592 of file ModuleSummaryIndex.h.
Referenced by addGlobalValueSummary().
|
inline |
Definition at line 1374 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1375 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1439 of file ModuleSummaryIndex.h.
References discoverNodes(), llvm::FunctionSummary::makeDummyFunctionSummary(), and P.
bool ModuleSummaryIndex::canImportGlobalVar | ( | GlobalValueSummary * | S, |
bool | AnalyzeRefs | ||
) | const |
Checks if we can import global variable from another module.
Definition at line 320 of file ModuleSummaryIndex.cpp.
References llvm::GlobalValueSummary::getBaseObject(), ImportConstantsWithRefs, llvm::GlobalValue::isInterposableLinkage(), isReadOnly(), isWriteOnly(), llvm::GlobalValueSummary::linkage(), and llvm::GlobalValueSummary::notEligibleToImport().
Referenced by propagateAttributes().
|
inline |
Definition at line 1563 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1564 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1560 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1561 of file ModuleSummaryIndex.h.
void ModuleSummaryIndex::collectDefinedFunctionsForModule | ( | StringRef | ModulePath, |
GVSummaryMapTy & | GVSummaryMap | ||
) | const |
Collect for the given module the list of functions it defines (GUID -> Summary).
Definition at line 152 of file ModuleSummaryIndex.cpp.
|
inline |
Collect for each module the list of Summaries it defines (GUID -> Summary).
Definition at line 1771 of file ModuleSummaryIndex.h.
Referenced by exportToDot().
|
inlinestatic |
Convenience function for doing a DFS on a ValueInfo.
Marks the function in the FunctionHasParent map.
Definition at line 1407 of file ModuleSummaryIndex.h.
References assert(), llvm::CallingConv::C, discoverNodes(), and F.
Referenced by calculateCallGraphRoot(), and discoverNodes().
LLVM_DUMP_METHOD void ModuleSummaryIndex::dump | ( | ) | const |
Dump to stderr (for debugging).
Definition at line 4982 of file AsmWriter.cpp.
References llvm::dbgs(), and print().
LLVM_DUMP_METHOD void ModuleSummaryIndex::dumpSCCs | ( | raw_ostream & | OS | ) |
Print out strongly connected components for debugging.
Definition at line 355 of file ModuleSummaryIndex.cpp.
|
inline |
Definition at line 1503 of file ModuleSummaryIndex.h.
Referenced by getFlags().
|
inline |
Definition at line 1376 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1377 of file ModuleSummaryIndex.h.
void ModuleSummaryIndex::exportToDot | ( | raw_ostream & | OS, |
const DenseSet< GlobalValue::GUID > & | GUIDPreservedSymbols | ||
) | const |
Export summary to dot file for GraphViz.
Definition at line 536 of file ModuleSummaryIndex.cpp.
References A, assert(), Attributes, collectDefinedGVSummariesPerModule(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), defineExternalNode(), E, llvm::sys::path::filename(), Flags, getModuleId(), getNodeLabel(), getValueInfo(), hasConstantFlag(), hasReadOnlyFlag(), hasWriteOnlyFlag(), OS, and VI.
|
inline |
Find the summary for global GUID
in module ModuleId
, or nullptr if not found.
Definition at line 1618 of file ModuleSummaryIndex.h.
References findSummaryInModule(), and getValueInfo().
|
inline |
Find the summary for ValueInfo VI
in module ModuleId
, or nullptr if not found.
Definition at line 1604 of file ModuleSummaryIndex.h.
References llvm::find_if(), and VI.
Referenced by findSummaryInModule().
|
inline |
Definition at line 1370 of file ModuleSummaryIndex.h.
uint64_t ModuleSummaryIndex::getFlags | ( | ) | const |
Definition at line 92 of file ModuleSummaryIndex.cpp.
References enableSplitLTOUnit(), Flags, hasSyntheticEntryCounts(), partiallySplitLTOUnits(), skipModuleByDistributedBackend(), withAttributePropagation(), withDSOLocalPropagation(), withGlobalValueDeadStripping(), and withWholeProgramVisibility().
|
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 1664 of file ModuleSummaryIndex.h.
References getGlobalNameForLocal(), and Name.
Referenced by getGlobalNameForLocal(), and llvm::updateIndexWPDForExports().
|
inlinestatic |
Definition at line 1670 of file ModuleSummaryIndex.h.
References Name, and llvm::SmallString< InternalLen >::str().
|
inline |
Returns the first GlobalValueSummary for GV
, asserting that there is only one if PerModuleIndex
.
Definition at line 1628 of file ModuleSummaryIndex.h.
References assert(), getGlobalValueSummary(), llvm::GlobalValue::getGUID(), and llvm::Value::hasName().
Referenced by getGlobalValueSummary().
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 170 of file ModuleSummaryIndex.cpp.
References assert(), getValueInfo(), and VI.
|
inline |
Return the GUID for OriginalId
in the OidGuidMap.
Definition at line 1555 of file ModuleSummaryIndex.h.
References I.
|
inline |
Return module entry for module with the given ModPath
.
Definition at line 1696 of file ModuleSummaryIndex.h.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
|
inline |
Get the module SHA1 hash recorded for the given module path.
Definition at line 1656 of file ModuleSummaryIndex.h.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
Get the module ID recorded for the given module path.
Definition at line 1651 of file ModuleSummaryIndex.h.
References llvm::StringMap< ValueTy, AllocatorTy >::lookup().
Referenced by exportToDot().
|
inlinestatic |
Helper to obtain the unpromoted name for a global value (or the original name if not promoted).
Split off the rightmost ".llvm.${hash}" suffix, because it is possible in certain clients (not clang at the moment) for two rounds of ThinLTO optimization and therefore promotion to occur.
Definition at line 1681 of file ModuleSummaryIndex.h.
References Name.
Referenced by llvm::thinLTOInternalizeModule().
|
inline |
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId
.
This accessor can mutate the map and therefore should not be used in the ThinLTO backends.
Definition at line 1748 of file ModuleSummaryIndex.h.
|
inline |
Return an existing or new TypeIdSummary entry for TypeId
.
This accessor can mutate the map and therefore should not be used in the ThinLTO backends.
Definition at line 1714 of file ModuleSummaryIndex.h.
References llvm::GlobalValue::getGUID().
Referenced by parseTypeIdSummaryRecord().
|
inline |
Return a ValueInfo for GV
and mark it as belonging to GV.
Definition at line 1547 of file ModuleSummaryIndex.h.
References assert(), and llvm::GlobalValue::getGUID().
|
inline |
Return a ValueInfo for GUID
.
Definition at line 1529 of file ModuleSummaryIndex.h.
Referenced by addGlobalValueSummary().
|
inline |
Return a ValueInfo for GUID
setting value Name
.
Definition at line 1539 of file ModuleSummaryIndex.h.
|
inlinestaticconstexpr |
Definition at line 1361 of file ModuleSummaryIndex.h.
Referenced by checkCombinedSummaryForTesting().
Definition at line 1389 of file ModuleSummaryIndex.h.
References assert().
|
inline |
For the given TypeId
, this returns the TypeIdCompatibleVtableMap entry if present in the summary map.
This may be used when importing.
Definition at line 1755 of file ModuleSummaryIndex.h.
References I.
|
inline |
Definition at line 1734 of file ModuleSummaryIndex.h.
References getTypeIdSummary().
|
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 1726 of file ModuleSummaryIndex.h.
References llvm::GlobalValue::getGUID().
Referenced by getTypeIdSummary().
|
inline |
Return a ValueInfo for the index value_type (convenient when iterating index).
Definition at line 1518 of file ModuleSummaryIndex.h.
Referenced by exportToDot(), findSummaryInModule(), getGlobalValueSummary(), and isGUIDLive().
|
inline |
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
Definition at line 1523 of file ModuleSummaryIndex.h.
References I.
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 1705 of file ModuleSummaryIndex.h.
References llvm::StringMap< ValueTy, AllocatorTy >::count().
Referenced by llvm::FunctionImportGlobalProcessing::FunctionImportGlobalProcessing().
|
inline |
Definition at line 1509 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1493 of file ModuleSummaryIndex.h.
Referenced by getFlags().
|
inline |
Definition at line 1365 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1511 of file ModuleSummaryIndex.h.
References llvm::GlobalValueSummary::isLive().
Referenced by isGUIDLive(), and propagateAttributes().
bool ModuleSummaryIndex::isGUIDLive | ( | GlobalValue::GUID | GUID | ) | const |
Definition at line 180 of file ModuleSummaryIndex.cpp.
References getValueInfo(), I, isGlobalValueLive(), and VI.
|
inline |
Definition at line 1486 of file ModuleSummaryIndex.h.
References llvm::GlobalVarSummary::maybeReadOnly().
Referenced by canImportGlobalVar().
|
inline |
Definition at line 1489 of file ModuleSummaryIndex.h.
References llvm::GlobalVarSummary::maybeWriteOnly().
Referenced by canImportGlobalVar().
|
inline |
Table of modules, containing hash and id.
Definition at line 1646 of file ModuleSummaryIndex.h.
|
inline |
Table of modules, containing module hash and id.
Definition at line 1641 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1506 of file ModuleSummaryIndex.h.
Referenced by getFlags().
void ModuleSummaryIndex::print | ( | raw_ostream & | OS, |
bool | IsForDebug = false |
||
) | const |
Print to an output stream.
Definition at line 4920 of file AsmWriter.cpp.
References OS.
Referenced by dump().
void ModuleSummaryIndex::propagateAttributes | ( | const DenseSet< GlobalValue::GUID > & | PreservedSymbols | ) |
Do the access attribute and DSOLocal propagation in combined index.
Definition at line 250 of file ModuleSummaryIndex.cpp.
References llvm::AreStatisticsEnabled(), assert(), canImportGlobalVar(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), isGlobalValueLive(), llvm::none_of(), P, propagateAttributesToRefs(), PropagateAttrs, setWithAttributePropagation(), and setWithDSOLocalPropagation().
|
inline |
Definition at line 1399 of file ModuleSummaryIndex.h.
References assert().
Definition at line 1536 of file ModuleSummaryIndex.h.
References llvm::StringSaver::save(), and llvm::String.
|
inline |
Definition at line 1372 of file ModuleSummaryIndex.h.
References llvm::CallingConv::C.
|
inline |
Definition at line 1504 of file ModuleSummaryIndex.h.
Referenced by setFlags().
void ModuleSummaryIndex::setFlags | ( | uint64_t | Flags | ) |
Definition at line 113 of file ModuleSummaryIndex.cpp.
References assert(), Flags, setEnableSplitLTOUnit(), setHasSyntheticEntryCounts(), setPartiallySplitLTOUnits(), setSkipModuleByDistributedBackend(), setWithAttributePropagation(), setWithDSOLocalPropagation(), setWithGlobalValueDeadStripping(), and setWithWholeProgramVisibility().
|
inline |
Definition at line 1494 of file ModuleSummaryIndex.h.
Referenced by setFlags().
|
inline |
Definition at line 1507 of file ModuleSummaryIndex.h.
Referenced by setFlags().
|
inline |
Definition at line 1499 of file ModuleSummaryIndex.h.
Referenced by setFlags().
|
inline |
Definition at line 1476 of file ModuleSummaryIndex.h.
Referenced by propagateAttributes(), and setFlags().
|
inline |
Definition at line 1481 of file ModuleSummaryIndex.h.
Referenced by propagateAttributes(), and setFlags().
|
inline |
Definition at line 1471 of file ModuleSummaryIndex.h.
Referenced by setFlags().
|
inline |
Definition at line 1484 of file ModuleSummaryIndex.h.
Referenced by setFlags().
|
inline |
Definition at line 1378 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1496 of file ModuleSummaryIndex.h.
Referenced by getFlags().
Definition at line 1380 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1740 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1709 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1475 of file ModuleSummaryIndex.h.
Referenced by getFlags().
|
inline |
Definition at line 1480 of file ModuleSummaryIndex.h.
Referenced by getFlags().
|
inline |
Definition at line 1468 of file ModuleSummaryIndex.h.
Referenced by getFlags().
|
inline |
Definition at line 1483 of file ModuleSummaryIndex.h.
Referenced by getFlags(), and llvm::lto::thinBackend().
|
staticconstexpr |
Definition at line 1358 of file ModuleSummaryIndex.h.