9#ifndef LLVM_TRANSFORMS_IPO_FUNCTIONIMPORT_H
10#define LLVM_TRANSFORMS_IPO_FUNCTIONIMPORT_H
22#include <system_error>
90 std::unique_ptr<ImportFailureInfo>>>;
129 auto Key = std::make_pair(FromModule, GUID);
130 auto InsertResult = TheTable.try_emplace(
Key, TheTable.size());
131 return makeIDPair(InsertResult.first->second);
136 std::optional<std::pair<ImportIDTy, ImportIDTy>>
138 auto Key = std::make_pair(FromModule, GUID);
139 auto It = TheTable.find(
Key);
140 if (It != TheTable.end())
141 return makeIDPair(It->second);
147 std::tuple<StringRef, GlobalValue::GUID, GlobalValueSummary::ImportKind>
152 auto It = TheTable.begin() + (ImportID >> 1);
155 return std::make_tuple(FromModule, GUID, Kind);
159 std::tuple<StringRef, GlobalValue::GUID, GlobalValueSummary::ImportKind>
166 static std::pair<ImportIDTy, ImportIDTy> makeIDPair(
ImportIDTy Index) {
169 return std::make_pair(Def, Decl);
176 class SortedImportList;
227 LLVM_ABI std::optional<GlobalValueSummary::ImportKind>
249 bool(
const std::pair<StringRef, GlobalValue::GUID> &,
250 const std::pair<StringRef, GlobalValue::GUID> &)>
252 : IDs(ImportMap.IDs), Imports(
iterator_range(ImportMap.Imports)) {
256 -> std::pair<StringRef, GlobalValue::GUID> {
257 auto Tuple = IDs.lookup(Id);
258 return std::make_pair(std::get<0>(Tuple), std::get<1>(Tuple));
280 : ImportIDs(), EmptyList(ImportIDs), ListsImpl(
Size) {}
283 return ListsImpl.try_emplace(DestMod, ImportIDs).first->second;
287 auto It = ListsImpl.find(DestMod);
288 if (It != ListsImpl.end())
293 size_t size()
const {
return ListsImpl.size(); }
312 std::function<Expected<std::unique_ptr<Module>>(
StringRef Identifier)>;
316 bool ClearDSOLocalOnDeclarations)
317 : Index(Index), ModuleLoader(
std::
move(ModuleLoader)),
318 ClearDSOLocalOnDeclarations(ClearDSOLocalOnDeclarations) {}
322 const ImportMapTy &ImportList);
335 bool ClearDSOLocalOnDeclarations;
393 const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
394 const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
400 const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
401 const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
423 StringRef ModulePath,
424 const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
425 const FunctionImporter::ImportMapTy &ImportList,
436 StringRef ModulePath,
438 function_ref<
void(
const std::string &)>
F);
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseSet and SmallDenseSet classes.
This header defines various interfaces for pass management in LLVM.
Machine Check Debug Module
static cl::opt< std::string > OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-"))
This file implements a map that provides insertion order iteration.
static cl::opt< bool > PropagateAttrs("propagate-attrs", cl::init(true), cl::Hidden, cl::desc("Propagate attributes in index"))
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Implements a dense probed hash-table based set.
Tagged union holding either a T or a Error.
The function importing pass.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
std::pair< ImportIDTy, ImportIDTy > createImportIDs(StringRef FromModule, GlobalValue::GUID GUID)
ImportIDTable(const ImportIDTable &)=delete
ImportIDTable & operator=(const ImportIDTable &)=delete
std::tuple< StringRef, GlobalValue::GUID, GlobalValueSummary::ImportKind > lookup(ImportIDTy ImportID) const
std::optional< std::pair< ImportIDTy, ImportIDTy > > getImportIDs(StringRef FromModule, GlobalValue::GUID GUID)
std::tuple< StringRef, GlobalValue::GUID, GlobalValueSummary::ImportKind > operator()(ImportIDTable::ImportIDTy ImportID) const
const_iterator begin() const
const ImportMapTy & lookup(StringRef DestMod) const
const_iterator end() const
DenseMap< StringRef, ImportMapTy >::const_iterator const_iterator
ImportMapTy & operator[](StringRef DestMod)
ImportListsTy(size_t Size)
The map maintains the list of imports.
LLVM_ABI AddDefinitionStatus addDefinition(StringRef FromModule, GlobalValue::GUID GUID)
ImportMapTy(ImportIDTable &IDs)
void addGUID(StringRef FromModule, GlobalValue::GUID GUID, GlobalValueSummary::ImportKind ImportKind)
LLVM_ABI SmallVector< StringRef, 0 > getSourceModules() const
LLVM_ABI std::optional< GlobalValueSummary::ImportKind > getImportType(StringRef FromModule, GlobalValue::GUID GUID) const
LLVM_ABI void maybeAddDeclaration(StringRef FromModule, GlobalValue::GUID GUID)
friend class SortedImportList
SortedImportList(const ImportMapTy &ImportMap, llvm::function_ref< bool(const std::pair< StringRef, GlobalValue::GUID > &, const std::pair< StringRef, GlobalValue::GUID > &)> Comp)
LLVM_ABI Expected< bool > importFunctions(Module &M, const ImportMapTy &ImportList)
Import functions in Module M based on the supplied import list.
DenseMap< GlobalValue::GUID, std::tuple< unsigned, const GlobalValueSummary *, std::unique_ptr< ImportFailureInfo > > > ImportThresholdsTy
Map of callee GUID considered for import into a given module to a pair consisting of the largest thre...
static LLVM_ABI bool forceImportAll(const cl::LibraryOptionsContext &C)
FunctionImporter(const ModuleSummaryIndex &Index, ModuleLoaderTy ModuleLoader, bool ClearDSOLocalOnDeclarations)
Create a Function Importer.
ImportFailureReason
The different reasons selectCallee will chose not to import a candidate.
@ LocalLinkageNotInModule
DenseSet< ValueInfo > ExportSetTy
The set contains an entry for every global value that the module exports.
std::function< Expected< std::unique_ptr< Module > >(StringRef Identifier)> ModuleLoaderTy
A function of this type is used to load modules referenced by the index.
Function and variable summary information to aid decisions and implementation of importing.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
This class implements a map that also provides access to all stored values in a deterministic order.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This namespace contains all of the command line option processing machinery.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void computeDeadSymbolsWithConstProp(const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, function_ref< PrevailingType(GlobalValue::GUID)> isPrevailing, bool ImportEnabled)
Compute dead symbols and run constant propagation in combined index after that.
@ Unknown
Not known to have no common set bits.
DenseMap< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module,...
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
LLVM_ABI bool convertToDeclaration(GlobalValue &GV)
Converts value GV to declaration, or replaces with a declaration if it is an alias.
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI void computeDeadSymbolsAndUpdateIndirectCalls(const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols, function_ref< PrevailingType(GlobalValue::GUID)> isPrevailing)
Compute all the symbols that are "dead": i.e these that can't be reached in the graph from any of the...
std::map< std::string, GVSummaryMapTy, std::less<> > ModuleToSummariesForIndexTy
Map of a module name to the GUIDs and summaries we will import from that module.
LLVM_ABI void ComputeCrossModuleImport(const cl::LibraryOptionsContext &LibraryOptions, const ModuleSummaryIndex &Index, const DenseMap< StringRef, GVSummaryMapTy > &ModuleToDefinedGVSummaries, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, FunctionImporter::ImportListsTy &ImportLists, DenseMap< StringRef, FunctionImporter::ExportSetTy > &ExportLists)
Compute all the imports and exports for every module in the Index.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI void updateIndirectCalls(ModuleSummaryIndex &Index)
Update call edges for indirect calls to local functions added from SamplePGO when needed.
LLVM_ABI void thinLTOInternalizeModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Internalize TheModule based on the information recorded in the summaries during global summary-based ...
LLVM_ABI void gatherImportedSummariesForModule(StringRef ModulePath, const DenseMap< StringRef, GVSummaryMapTy > &ModuleToDefinedGVSummaries, const FunctionImporter::ImportMapTy &ImportList, ModuleToSummariesForIndexTy &ModuleToSummariesForIndex, GVSummaryPtrSet &DecSummaries)
Compute the set of summaries needed for a ThinLTO backend compilation of ModulePath.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void processImportsFiles(StringRef ModulePath, const ModuleToSummariesForIndexTy &ModuleToSummariesForIndex, function_ref< void(const std::string &)> F)
Call F passing each of the files module ModulePath will import from.
PrevailingType
PrevailingType enum used as a return type of callback passed to computeDeadSymbolsAndUpdateIndirectCa...
SmallPtrSet< GlobalValueSummary *, 0 > GVSummaryPtrSet
A set of global value summary pointers.
LLVM_ABI Error EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const ModuleToSummariesForIndexTy &ModuleToSummariesForIndex)
Emit into OutputFilename the files module ModulePath will import from.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void thinLTOFinalizeInModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals, bool PropagateAttrs)
Based on the information recorded in the summaries during global summary-based analysis:
Implement std::hash so that hash_code can be used in STL containers.
ImportFailureInfo(ValueInfo VI, CalleeInfo::HotnessType MaxHotness, ImportFailureReason Reason, unsigned Attempts)
CalleeInfo::HotnessType MaxHotness
ImportFailureReason Reason
A CRTP mix-in for passes that can be skipped.
Struct that holds a reference to a particular GUID in a global value summary.