LLVM 20.0.0git
|
The function importer is automatically importing function from other modules based on the provided summary informations. More...
#include "llvm/Transforms/IPO/FunctionImport.h"
Classes | |
struct | ImportFailureInfo |
Information optionally tracked for candidates the importer decided not to import. More... | |
Public Types | |
enum class | ImportFailureReason { None , GlobalVar , NotLive , TooLarge , InterposableLinkage , LocalLinkageNotInModule , NotEligible , NoInline } |
The different reasons selectCallee will chose not to import a candidate. More... | |
using | FunctionsToImportTy = std::unordered_map< GlobalValue::GUID, GlobalValueSummary::ImportKind > |
The functions to import from a source module and their import type. | |
using | ImportThresholdsTy = DenseMap< GlobalValue::GUID, std::tuple< unsigned, const GlobalValueSummary *, std::unique_ptr< ImportFailureInfo > > > |
Map of callee GUID considered for import into a given module to a pair consisting of the largest threshold applied when deciding whether to import it and, if we decided to import, a pointer to the summary instance imported. | |
using | ImportMapTy = DenseMap< StringRef, FunctionsToImportTy > |
The map contains an entry for every module to import from, the key being the module identifier to pass to the ModuleLoader. | |
using | ExportSetTy = DenseSet< ValueInfo > |
The set contains an entry for every global value that the module exports. | |
using | ModuleLoaderTy = std::function< Expected< std::unique_ptr< Module > >(StringRef Identifier)> |
A function of this type is used to load modules referenced by the index. | |
Public Member Functions | |
FunctionImporter (const ModuleSummaryIndex &Index, ModuleLoaderTy ModuleLoader, bool ClearDSOLocalOnDeclarations) | |
Create a Function Importer. | |
Expected< bool > | importFunctions (Module &M, const ImportMapTy &ImportList) |
Import functions in Module M based on the supplied import list. | |
The function importer is automatically importing function from other modules based on the provided summary informations.
Definition at line 33 of file FunctionImport.h.
The set contains an entry for every global value that the module exports.
Depending on the user context, this container is allowed to contain definitions, declarations or a mix of both.
Definition at line 110 of file FunctionImport.h.
using llvm::FunctionImporter::FunctionsToImportTy = std::unordered_map<GlobalValue::GUID, GlobalValueSummary::ImportKind> |
The functions to import from a source module and their import type.
Note we choose unordered_map over (Small)DenseMap. The number of imports from a source module could be small but DenseMap size grows to 64 quickly and not memory efficient (see https://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h)
Definition at line 40 of file FunctionImport.h.
The map contains an entry for every module to import from, the key being the module identifier to pass to the ModuleLoader.
The value is the set of functions to import. The module identifier strings must be owned elsewhere, typically by the in-memory ModuleSummaryIndex the importing decisions are made from (the module path for each summary is owned by the index's module path string table).
Definition at line 105 of file FunctionImport.h.
using llvm::FunctionImporter::ImportThresholdsTy = DenseMap<GlobalValue::GUID, std::tuple<unsigned, const GlobalValueSummary *, std::unique_ptr<ImportFailureInfo> >> |
Map of callee GUID considered for import into a given module to a pair consisting of the largest threshold applied when deciding whether to import it and, if we decided to import, a pointer to the summary instance imported.
If we decided not to import, the summary will be nullptr.
Definition at line 94 of file FunctionImport.h.
using llvm::FunctionImporter::ModuleLoaderTy = std::function<Expected<std::unique_ptr<Module> >(StringRef Identifier)> |
A function of this type is used to load modules referenced by the index.
Definition at line 113 of file FunctionImport.h.
|
strong |
The different reasons selectCallee will chose not to import a candidate.
Enumerator | |
---|---|
None | |
GlobalVar | |
NotLive | |
TooLarge | |
InterposableLinkage | |
LocalLinkageNotInModule | |
NotEligible | |
NoInline |
Definition at line 45 of file FunctionImport.h.
|
inline |
Create a Function Importer.
Definition at line 117 of file FunctionImport.h.
Expected< bool > FunctionImporter::importFunctions | ( | Module & | M, |
const ImportMapTy & | ImportList | ||
) |
Import functions in Module M
based on the supplied import list.
Definition at line 1770 of file FunctionImport.cpp.
References assert(), llvm::createStringError(), llvm::dbgs(), llvm::GlobalValueSummary::Definition, EnableImportMetadata, llvm::EnableMemProfContextDisambiguation, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), F, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MDNode::get(), llvm::GlobalValue::getAliaseeObject(), llvm::SetVector< T, Vector, Set, N >::getArrayRef(), llvm::Module::getContext(), llvm::GlobalValue::getGUID(), llvm::Module::getModuleIdentifier(), llvm::Value::getName(), llvm::Module::getSourceFileName(), llvm::SetVector< T, Vector, Set, N >::insert(), internalizeGVsAfterImport(), llvm::invalid_argument, LLVM_DEBUG, llvm::GlobalValue::materialize(), llvm::IRMover::move(), Name, PrintImports, llvm::renameModuleForThinLTO(), replaceAliasWithAliasee(), llvm::SetVector< T, Vector, Set, N >::size(), llvm::Expected< T >::takeError(), llvm::dwarf::toString(), and llvm::UpgradeDebugInfo().
Referenced by doImportingForModuleForTest(), and llvm::lto::thinBackend().