|
LLVM
10.0.0
|
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 |
| gvsummary_iterator | begin () |
| const_gvsummary_iterator | begin () const |
| gvsummary_iterator | end () |
| const_gvsummary_iterator | end () const |
| size_t | size () const |
| FunctionSummary | calculateCallGraphRoot () |
| bool | withGlobalValueDeadStripping () const |
| void | setWithGlobalValueDeadStripping () |
| bool | withAttributePropagation () const |
| void | setWithAttributePropagation () |
| 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 | 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). More... | |
| 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... | |
| StringRef | saveString (StringRef String) |
| ValueInfo | getOrInsertValueInfo (GlobalValue::GUID GUID, StringRef Name) |
Return a ValueInfo for GUID setting value Name. 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 (const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary) |
| Add a global value summary for a value. 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 (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... | |
| GlobalValueSummary * | findSummaryInModule (ValueInfo VI, StringRef ModuleId) const |
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found. More... | |
| GlobalValueSummary * | findSummaryInModule (GlobalValue::GUID ValueGUID, StringRef ModuleId) const |
Find the summary for global GUID in module ModuleId, or nullptr if not found. More... | |
| GlobalValueSummary * | getGlobalValueSummary (const GlobalValue &GV, bool PerModuleIndex=true) const |
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex. More... | |
| GlobalValueSummary * | getGlobalValueSummary (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 ModuleHash & | getModuleHash (const StringRef ModPath) const |
| Get the module SHA1 hash recorded for the given module path. More... | |
| 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. More... | |
| ModuleInfo * | getModule (StringRef ModPath) |
Return module entry for module with the given ModPath. More... | |
| bool | hasExportedFunctions (const Module &M) const |
| Check if the given Module has any functions available for exporting in the index. More... | |
| const TypeIdSummaryMapTy & | typeIds () const |
| TypeIdSummary & | getOrInsertTypeIdSummary (StringRef TypeId) |
Return an existing or new TypeIdSummary entry for TypeId. More... | |
| 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). More... | |
| TypeIdSummary * | getTypeIdSummary (StringRef TypeId) |
| const std::map< std::string, TypeIdCompatibleVtableInfo > & | typeIdCompatibleVtableMap () const |
| TypeIdCompatibleVtableInfo & | getOrInsertTypeIdCompatibleVtableSummary (StringRef TypeId) |
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId. More... | |
| Optional< TypeIdCompatibleVtableInfo > | getTypeIdCompatibleVtableSummary (StringRef TypeId) const |
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map. More... | |
| void | collectDefinedFunctionsForModule (StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const |
| Collect for the given module the list of functions it defines (GUID -> Summary). More... | |
| template<class Map > | |
| void | collectDefinedGVSummariesPerModule (Map &ModuleToDefinedGVSummaries) const |
| Collect for each module the list of Summaries it defines (GUID -> Summary). More... | |
| void | print (raw_ostream &OS, bool IsForDebug=false) const |
| Print to an output stream. More... | |
| void | dump () const |
| Dump to stderr (for debugging). More... | |
| void | exportToDot (raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const |
| Export summary to dot file for GraphViz. More... | |
| void | dumpSCCs (raw_ostream &OS) |
| Print out strongly connected components for debugging. More... | |
| void | propagateAttributes (const DenseSet< GlobalValue::GUID > &PreservedSymbols) |
| Analyze index and detect unmodified globals. More... | |
| bool | canImportGlobalVar (GlobalValueSummary *S, bool AnalyzeRefs) const |
| Checks if we can import global variable from another module. More... | |
Static Public Member Functions | |
| static void | discoverNodes (ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent) |
| Convenience function for doing a DFS on a ValueInfo. More... | |
| 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... | |
Static Public Attributes | |
| static constexpr uint64_t | BitcodeSummaryVersion = 8 |
Class to hold module path string table and global value map, and encapsulate methods for operating on them.
Definition at line 919 of file ModuleSummaryIndex.h.
Definition at line 1279 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 994 of file ModuleSummaryIndex.h.
|
inline |
Add a global value summary for a value.
Definition at line 1167 of file ModuleSummaryIndex.h.
Referenced by llvm::buildModuleSummaryIndex(), computeAliasSummary(), computeFunctionSummary(), and computeVariableSummary().
|
inline |
Add a global value summary for a value of the given name.
Definition at line 1173 of file ModuleSummaryIndex.h.
References llvm::GlobalValue::getGUID().
|
inline |
Add a global value summary for the given ValueInfo.
Definition at line 1180 of file ModuleSummaryIndex.h.
References llvm::ValueInfo::getGUID(), llvm::ValueInfo::getRef(), and second.
|
inline |
Add a new module with the given Hash, mapped to the given ModID, and return a reference to the module.
Definition at line 1283 of file ModuleSummaryIndex.h.
References first, and llvm::StringMap< ValueTy, AllocatorTy >::insert().
|
inline |
Add an original name for the value of the given GUID.
Definition at line 1190 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1007 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1008 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1047 of file ModuleSummaryIndex.h.
References llvm::FunctionSummary::makeDummyFunctionSummary(), and P.
Referenced by llvm::GraphTraits< ModuleSummaryIndex * >::getEntryNode(), and initializeCounts().
| bool ModuleSummaryIndex::canImportGlobalVar | ( | GlobalValueSummary * | S, |
| bool | AnalyzeRefs | ||
| ) | const |
Checks if we can import global variable from another module.
Definition at line 207 of file ModuleSummaryIndex.cpp.
References llvm::GlobalValueSummary::getBaseObject(), llvm::GlobalValue::isInterposableLinkage(), llvm::ValueInfo::isReadOnly(), llvm::ValueInfo::isWriteOnly(), llvm::GlobalValueSummary::linkage(), LLVM_DUMP_METHOD, and llvm::GlobalValueSummary::notEligibleToImport().
Referenced by computeImportForReferencedGlobals().
|
inline |
Definition at line 1163 of file ModuleSummaryIndex.h.
Referenced by isDirectCall().
|
inline |
Definition at line 1164 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1160 of file ModuleSummaryIndex.h.
Referenced by isDirectCall().
|
inline |
Definition at line 1161 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 73 of file ModuleSummaryIndex.cpp.
Referenced by llvm::ComputeCrossModuleImportForModule().
|
inline |
Collect for each module the list of Summaries it defines (GUID -> Summary).
Definition at line 1365 of file ModuleSummaryIndex.h.
References llvm::dump(), and print().
Referenced by llvm::ThinLTOCodeGenerator::crossModuleImport(), llvm::ThinLTOCodeGenerator::emitImports(), llvm::ThinLTOCodeGenerator::gatherImportedSummariesForModule(), llvm::ThinLTOCodeGenerator::internalize(), and llvm::ThinLTOCodeGenerator::promote().
|
inlinestatic |
Convenience function for doing a DFS on a ValueInfo.
Marks the function in the FunctionHasParent map.
Definition at line 1015 of file ModuleSummaryIndex.h.
References assert(), C, llvm::FunctionSummary::calls(), llvm::dyn_cast(), F(), and llvm::ValueInfo::getSummaryList().
| LLVM_DUMP_METHOD void ModuleSummaryIndex::dump | ( | ) | const |
Dump to stderr (for debugging).
Definition at line 4498 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 241 of file ModuleSummaryIndex.cpp.
References add(), llvm::AMDGPU::HSAMD::Kernel::Key::Attrs, F(), I, llvm::Twine::isTriviallyEmpty(), Name, llvm::MipsISD::Ret, llvm::Twine::str(), and llvm::utostr().
|
inline |
Definition at line 1105 of file ModuleSummaryIndex.h.
Referenced by computeVariableSummary().
|
inline |
Definition at line 1009 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1010 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 408 of file ModuleSummaryIndex.cpp.
References assert(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), defineExternalNode(), E, llvm::sys::path::filename(), llvm::X86AS::FS, getNodeLabel(), hasReadOnlyFlag(), hasWriteOnlyFlag(), llvm::to_string(), and VI.
Referenced by llvm::lto::Config::addSaveTemps().
|
inline |
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
Definition at line 1202 of file ModuleSummaryIndex.h.
References llvm::find_if(), and llvm::ValueInfo::getSummaryList().
Referenced by checkVariableImport(), and llvm::computeLTOCacheKey().
|
inline |
Find the summary for global GUID in module ModuleId, or nullptr if not found.
Definition at line 1216 of file ModuleSummaryIndex.h.
|
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 1262 of file ModuleSummaryIndex.h.
References llvm::SmallString< InternalLen >::str(), and llvm::utostr().
Referenced by AddCalls(), and llvm::updateIndexWPDForExports().
|
inline |
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
Definition at line 1226 of file ModuleSummaryIndex.h.
References assert(), llvm::GlobalValue::getGUID(), and llvm::Value::hasName().
Referenced by llvm::buildModuleSummaryIndex().
| 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 91 of file ModuleSummaryIndex.cpp.
|
inline |
Return the GUID for OriginalId in the OidGuidMap.
Definition at line 1155 of file ModuleSummaryIndex.h.
References I.
Referenced by updateValueInfoForIndirectCalls().
|
inline |
Return module entry for module with the given ModPath.
Definition at line 1289 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 1254 of file ModuleSummaryIndex.h.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::end(), and llvm::StringMap< ValueTy, AllocatorTy >::find().
Referenced by AddCalls(), llvm::computeLTOCacheKey(), and llvm::updateIndexWPDForExports().
Get the module ID recorded for the given module path.
Definition at line 1249 of file ModuleSummaryIndex.h.
References llvm::StringMap< ValueTy, AllocatorTy >::lookup().
|
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 1274 of file ModuleSummaryIndex.h.
References llvm::StringRef::rsplit().
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 1342 of file ModuleSummaryIndex.h.
Referenced by parseTypeIdSummaryRecord(), and recordTypeIdCompatibleVtableReferences().
|
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 1307 of file ModuleSummaryIndex.h.
References llvm::GlobalValue::getGUID().
Referenced by AddCalls(), and parseTypeIdSummaryRecord().
|
inline |
Return a ValueInfo for GUID.
Definition at line 1129 of file ModuleSummaryIndex.h.
Referenced by computeFunctionSummary(), findRefEdges(), and recordTypeIdCompatibleVtableReferences().
|
inline |
Return a ValueInfo for GUID setting value Name.
Definition at line 1139 of file ModuleSummaryIndex.h.
|
inline |
Return a ValueInfo for GV and mark it as belonging to GV.
Definition at line 1147 of file ModuleSummaryIndex.h.
References assert(), and llvm::GlobalValue::getGUID().
|
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 1349 of file ModuleSummaryIndex.h.
References I, and llvm::None.
|
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 1319 of file ModuleSummaryIndex.h.
References llvm::GlobalValue::getGUID().
Referenced by llvm::updateIndexWPDForExports().
|
inline |
Definition at line 1327 of file ModuleSummaryIndex.h.
|
inline |
Return a ValueInfo for the index value_type (convenient when iterating index).
Definition at line 1118 of file ModuleSummaryIndex.h.
Referenced by AddCalls(), computeAliasSummary(), llvm::computeDeadSymbols(), ComputeImportForModule(), isGlobalVarSummary(), setLiveRoot(), and updateValueInfoForIndirectCalls().
|
inline |
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
Definition at line 1123 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 1298 of file ModuleSummaryIndex.h.
References llvm::StringMap< ValueTy, AllocatorTy >::count(), and llvm::Module::getModuleIdentifier().
Referenced by llvm::FunctionImportGlobalProcessing::FunctionImportGlobalProcessing().
|
inline |
Definition at line 1095 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1005 of file ModuleSummaryIndex.h.
Referenced by llvm::GraphTraits< ModuleSummaryIndex * >::getEntryNode().
|
inline |
Definition at line 1111 of file ModuleSummaryIndex.h.
References llvm::GlobalValueSummary::isLive().
Referenced by ComputeImportForModule(), dropDeadSymbols(), and selectCallee().
| bool ModuleSummaryIndex::isGUIDLive | ( | GlobalValue::GUID | GUID | ) | const |
Definition at line 101 of file ModuleSummaryIndex.cpp.
|
inline |
Definition at line 1088 of file ModuleSummaryIndex.h.
References llvm::GlobalVarSummary::maybeReadOnly().
Referenced by checkVariableImport().
|
inline |
Definition at line 1091 of file ModuleSummaryIndex.h.
References llvm::GlobalVarSummary::maybeWriteOnly().
Referenced by checkVariableImport(), and computeImportForReferencedGlobals().
|
inline |
Table of modules, containing module hash and id.
Definition at line 1239 of file ModuleSummaryIndex.h.
Referenced by llvm::ThinLTOCodeGenerator::crossModuleImport(), llvm::ThinLTOCodeGenerator::emitImports(), llvm::ThinLTOCodeGenerator::gatherImportedSummariesForModule(), llvm::ThinLTOCodeGenerator::internalize(), and llvm::ThinLTOCodeGenerator::promote().
|
inline |
Table of modules, containing hash and id.
Definition at line 1244 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1108 of file ModuleSummaryIndex.h.
Referenced by AddCalls(), and isDirectCall().
| void ModuleSummaryIndex::print | ( | raw_ostream & | OS, |
| bool | IsForDebug = false |
||
| ) | const |
Print to an output stream.
Definition at line 4456 of file AsmWriter.cpp.
References LLVM_DUMP_METHOD, and llvm::RISCVFenceField::W.
| void ModuleSummaryIndex::propagateAttributes | ( | const DenseSet< GlobalValue::GUID > & | PreservedSymbols | ) |
Analyze index and detect unmodified globals.
Definition at line 163 of file ModuleSummaryIndex.cpp.
References llvm::AreStatisticsEnabled(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), P, propagateAttributesToRefs(), and PropagateAttrs.
Referenced by llvm::computeDeadSymbolsWithConstProp().
Definition at line 1136 of file ModuleSummaryIndex.h.
References llvm::StringSaver::save().
|
inline |
Definition at line 1106 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1096 of file ModuleSummaryIndex.h.
Referenced by llvm::computeSyntheticCounts().
|
inline |
Definition at line 1109 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1101 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1084 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1079 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1011 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1098 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1334 of file ModuleSummaryIndex.h.
Referenced by AddCalls().
|
inline |
Definition at line 1302 of file ModuleSummaryIndex.h.
Referenced by llvm::computeLTOCacheKey().
|
inline |
Definition at line 1083 of file ModuleSummaryIndex.h.
|
inline |
Definition at line 1076 of file ModuleSummaryIndex.h.
Referenced by llvm::computeDeadSymbols().
|
static |
Definition at line 1003 of file ModuleSummaryIndex.h.
Referenced by llvm::FunctionSummary::specialRefCounts(), and writeTypeIdCompatibleVtableSummaryRecord().
1.8.13