35 #define DEBUG_TYPE "function-import"
39 STATISTIC(NumImportedFunctions,
"Number of functions imported");
40 STATISTIC(NumImportedModules,
"Number of modules imported from");
41 STATISTIC(NumDeadSymbols,
"Number of dead stripped symbols in index");
42 STATISTIC(NumLiveSymbols,
"Number of live symbols in index");
47 cl::desc(
"Only import functions with less than N instructions"));
52 cl::desc(
"As we import functions, multiply the "
53 "`import-instr-limit` threshold by this factor "
54 "before processing newly imported functions"));
59 cl::desc(
"As we import functions called from hot callsite, multiply the "
60 "`import-instr-limit` threshold by this factor "
61 "before processing newly imported functions"));
65 cl::desc(
"Multiply the `import-instr-limit` threshold for hot callsites"));
71 "Multiply the `import-instr-limit` threshold for critical callsites"));
76 cl::desc(
"Multiply the `import-instr-limit` threshold for cold callsites"));
79 cl::desc(
"Print imported functions"));
95 static std::unique_ptr<Module>
loadFile(
const std::string &FileName,
98 DEBUG(
dbgs() <<
"Loading '" << FileName <<
"'\n");
101 std::unique_ptr<Module> Result =
126 ArrayRef<std::unique_ptr<GlobalValueSummary>> CalleeSummaryList,
130 [&](
const std::unique_ptr<GlobalValueSummary> &SummaryPtr) {
131 auto *GVSummary = SummaryPtr.get();
135 if (
auto *AS = dyn_cast<AliasSummary>(GVSummary)) {
136 GVSummary = &AS->getAliasee();
146 auto *Summary = cast<FunctionSummary>(GVSummary);
159 CalleeSummaryList.size() > 1 &&
160 Summary->modulePath() != CallerModulePath)
166 if (Summary->notEligibleToImport())
171 if (It == CalleeSummaryList.end())
174 return cast<GlobalValueSummary>(It->get());
183 static void computeImportForFunction(
185 const unsigned Threshold,
const GVSummaryMapTy &DefinedGVSummaries,
189 for (
auto &Edge : Summary.
calls()) {
207 DEBUG(
dbgs() <<
"ignored! Target already in destination module.\n");
221 const auto NewThreshold =
222 Threshold * GetBonusMultiplier(Edge.second.Hotness);
224 auto *CalleeSummary = selectCallee(Index, VI.
getSummaryList(), NewThreshold,
226 if (!CalleeSummary) {
227 DEBUG(
dbgs() <<
"ignored! No qualifying callee with summary found.\n");
231 const FunctionSummary *ResolvedCalleeSummary;
232 if (isa<AliasSummary>(CalleeSummary)) {
233 ResolvedCalleeSummary = cast<FunctionSummary>(
234 &cast<AliasSummary>(CalleeSummary)->getAliasee());
237 "Unexpected alias to a non-linkonceODR in import list");
239 ResolvedCalleeSummary = cast<FunctionSummary>(CalleeSummary);
242 "selectCallee() didn't honor the threshold");
244 auto GetAdjustedThreshold = [](
unsigned Threshold,
bool IsHotCallsite) {
254 const auto AdjThreshold = GetAdjustedThreshold(Threshold, IsHotCallsite);
256 auto ExportModulePath = ResolvedCalleeSummary->
modulePath();
257 auto &ProcessedThreshold = ImportList[ExportModulePath][VI.
getGUID()];
261 if (ProcessedThreshold && ProcessedThreshold >= AdjThreshold) {
262 DEBUG(
dbgs() <<
"ignored! Target was already seen with Threshold "
263 << ProcessedThreshold <<
"\n");
266 bool PreviouslyImported = ProcessedThreshold != 0;
268 ProcessedThreshold = AdjThreshold;
272 auto &ExportList = (*ExportLists)[ExportModulePath];
273 ExportList.insert(VI.
getGUID());
274 if (!PreviouslyImported) {
281 for (
auto &Edge : ResolvedCalleeSummary->
calls()) {
282 auto CalleeGUID = Edge.first.getGUID();
283 ExportList.insert(CalleeGUID);
285 for (
auto &Ref : ResolvedCalleeSummary->
refs()) {
286 auto GUID = Ref.getGUID();
287 ExportList.insert(GUID);
300 static void ComputeImportForModule(
310 for (
auto &GVSummary : DefinedGVSummaries) {
312 DEBUG(
dbgs() <<
"Ignores Dead GUID: " << GVSummary.first <<
"\n");
315 auto *Summary = GVSummary.second;
316 if (
auto *AS = dyn_cast<AliasSummary>(Summary))
317 Summary = &AS->getAliasee();
318 auto *FuncSummary =
dyn_cast<FunctionSummary>(Summary);
322 DEBUG(
dbgs() <<
"Initalize import for " << GVSummary.first <<
"\n");
324 DefinedGVSummaries, Worklist, ImportList,
329 while (!Worklist.
empty()) {
331 auto *Summary = std::get<0>(FuncInfo);
332 auto Threshold = std::get<1>(FuncInfo);
333 auto GUID = std::get<2>(FuncInfo);
337 auto ExportModulePath = Summary->
modulePath();
338 auto &LatestProcessedThreshold = ImportList[ExportModulePath][GUID];
339 if (LatestProcessedThreshold > Threshold)
342 computeImportForFunction(*Summary, Index, Threshold, DefinedGVSummaries,
343 Worklist, ImportList, ExportLists);
356 for (
auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
357 auto &ImportList = ImportLists[DefinedGVSummaries.first()];
358 DEBUG(
dbgs() <<
"Computing import for Module '"
359 << DefinedGVSummaries.first() <<
"'\n");
360 ComputeImportForModule(DefinedGVSummaries.second, Index, ImportList,
369 for (
auto &ELI : ExportLists) {
370 const auto &DefinedGVSummaries =
371 ModuleToDefinedGVSummaries.lookup(ELI.first());
372 for (
auto EI = ELI.second.begin(); EI != ELI.second.end();) {
373 if (!DefinedGVSummaries.count(*EI))
374 EI = ELI.second.erase(EI);
381 DEBUG(
dbgs() <<
"Import/Export lists for " << ImportLists.
size()
383 for (
auto &ModuleImports : ImportLists) {
384 auto ModName = ModuleImports.first();
385 auto &Exports = ExportLists[ModName];
386 DEBUG(
dbgs() <<
"* Module " << ModName <<
" exports " << Exports.size()
387 <<
" functions. Imports from " << ModuleImports.second.size()
389 for (
auto &Src : ModuleImports.second) {
390 auto SrcModName = Src.first();
391 DEBUG(
dbgs() <<
" - " << Src.second.size() <<
" functions imported from "
392 << SrcModName <<
"\n");
409 DEBUG(
dbgs() <<
"Computing import for Module '" << ModulePath <<
"'\n");
410 ComputeImportForModule(FunctionSummaryMap, Index, ImportList);
413 DEBUG(
dbgs() <<
"* Module " << ModulePath <<
" imports from "
414 << ImportList.
size() <<
" modules.\n");
415 for (
auto &Src : ImportList) {
416 auto SrcModName = Src.first();
417 DEBUG(
dbgs() <<
" - " << Src.second.size() <<
" functions imported from "
418 << SrcModName <<
"\n");
429 if (GUIDPreservedSymbols.
empty())
432 unsigned LiveSymbols = 0;
435 for (
auto GUID : GUIDPreservedSymbols) {
444 for (
const auto &Entry : Index)
445 for (
auto &S : Entry.second.SummaryList)
447 DEBUG(
dbgs() <<
"Live root: " << Entry.first <<
"\n");
465 while (!Worklist.
empty()) {
468 for (
auto Ref : Summary->
refs())
470 if (
auto *FS = dyn_cast<FunctionSummary>(Summary.get()))
471 for (
auto Call : FS->calls())
473 if (
auto *AS = dyn_cast<AliasSummary>(Summary.get())) {
474 auto AliaseeGUID = AS->getAliasee().getOriginalName();
475 ValueInfo AliaseeVI = Index.getValueInfo(AliaseeGUID);
481 Index.setWithGlobalValueDeadStripping();
483 unsigned DeadSymbols = Index.size() - LiveSymbols;
484 DEBUG(
dbgs() << LiveSymbols <<
" symbols Live, and " << DeadSymbols
485 <<
" symbols Dead \n");
486 NumDeadSymbols += DeadSymbols;
487 NumLiveSymbols += LiveSymbols;
496 std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
498 ModuleToSummariesForIndex[ModulePath] =
499 ModuleToDefinedGVSummaries.
lookup(ModulePath);
501 for (
auto &ILI : ImportList) {
502 auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()];
503 const auto &DefinedGVSummaries =
504 ModuleToDefinedGVSummaries.
lookup(ILI.first());
505 for (
auto &GI : ILI.second) {
506 const auto &DS = DefinedGVSummaries.find(GI.first);
507 assert(DS != DefinedGVSummaries.end() &&
508 "Expected a defined summary for imported global value");
509 SummariesForIndex[GI.first] = DS->second;
522 for (
auto &ILI : ModuleImports)
523 ImportsOS << ILI.first() <<
"\n";
524 return std::error_code();
531 DEBUG(
dbgs() <<
"Converting to a declaration: `" << GV.getName() <<
"\n");
532 if (
Function *
F = dyn_cast<Function>(&GV)) {
536 V->setInitializer(
nullptr);
549 const auto &GS = DefinedGlobals.
find(GV.getGUID());
550 if (GS == DefinedGlobals.
end())
552 auto NewLinkage = GS->second->linkage();
553 if (NewLinkage == GV.getLinkage())
564 GV.setLinkage(NewLinkage);
577 ConvertToDeclaration(GV);
579 DEBUG(
dbgs() <<
"ODR fixing up linkage for `" << GV.getName() <<
"` from "
580 << GV.getLinkage() <<
" to " << NewLinkage <<
"\n");
581 GV.setLinkage(NewLinkage);
586 auto *GO = dyn_cast_or_null<GlobalObject>(&GV);
587 if (GO && GO->isDeclarationForLinker() && GO->hasComdat())
588 GO->setComdat(
nullptr);
592 for (
auto &GV : TheModule)
594 for (
auto &GV : TheModule.globals())
596 for (
auto &GV : TheModule.aliases())
610 AsmUndefinedRefs.
insert(Name);
615 auto MustPreserveGV = [&](
const GlobalValue &GV) ->
bool {
617 if (AsmUndefinedRefs.
count(GV.getName()))
621 auto GS = DefinedGlobals.
find(GV.getGUID());
622 if (GS == DefinedGlobals.
end()) {
634 if (GS == DefinedGlobals.
end()) {
658 DEBUG(
dbgs() <<
"Starting import for Module "
660 unsigned ImportedCount = 0;
664 std::set<StringRef> ModuleNameOrderedList;
665 for (
auto &FunctionsToImportPerModule : ImportList) {
666 ModuleNameOrderedList.insert(FunctionsToImportPerModule.first());
668 for (
auto &
Name : ModuleNameOrderedList) {
670 const auto &FunctionsToImportPerModule = ImportList.find(
Name);
671 assert(FunctionsToImportPerModule != ImportList.end());
674 return SrcModuleOrErr.takeError();
675 std::unique_ptr<Module> SrcModule = std::move(*SrcModuleOrErr);
681 if (
Error Err = SrcModule->materializeMetadata())
682 return std::move(Err);
684 auto &ImportGUIDs = FunctionsToImportPerModule->second;
690 auto GUID =
F.getGUID();
691 auto Import = ImportGUIDs.count(GUID);
692 DEBUG(
dbgs() << (
Import ?
"Is" :
"Not") <<
" importing function " << GUID
693 <<
" " <<
F.getName() <<
" from "
694 << SrcModule->getSourceFileName() <<
"\n");
696 if (
Error Err =
F.materialize())
697 return std::move(Err);
701 "thinlto_src_module",
705 SrcModule->getSourceFileName())}));
713 auto GUID = GV.getGUID();
714 auto Import = ImportGUIDs.count(GUID);
715 DEBUG(
dbgs() << (
Import ?
"Is" :
"Not") <<
" importing global " << GUID
716 <<
" " << GV.getName() <<
" from "
717 << SrcModule->getSourceFileName() <<
"\n");
719 if (
Error Err = GV.materialize())
720 return std::move(Err);
721 GlobalsToImport.
insert(&GV);
726 if (FunctionImportGlobalProcessing::doImportAsDefinition(
727 &GA, &GlobalsToImport)) {
728 GlobalsToImport.
insert(&GA);
734 auto GUID = GA.getGUID();
735 auto Import = ImportGUIDs.count(GUID);
737 <<
" " << GA.getName() <<
" from "
738 << SrcModule->getSourceFileName() <<
"\n");
746 "Unexpected alias to a non-linkonceODR in import list");
748 if (!GlobalsToImport.
count(GO))
750 <<
" " << GO->
getName() <<
" from "
751 << SrcModule->getSourceFileName() <<
"\n");
754 return std::move(Err);
755 GlobalsToImport.
insert(GO);
756 if (
Error Err = GA.materialize())
757 return std::move(Err);
758 GlobalsToImport.
insert(&GA);
771 for (
const auto *GV : GlobalsToImport)
773 <<
" from " << SrcModule->getSourceFileName() <<
"\n";
781 ImportedCount += GlobalsToImport.
size();
782 NumImportedModules++;
785 NumImportedFunctions += ImportedCount;
787 DEBUG(
dbgs() <<
"Imported " << ImportedCount <<
" functions for Module "
789 return ImportedCount;
796 cl::desc(
"The summary file to use for function importing."));
799 if (SummaryFile.empty())
803 if (!IndexPtrOrErr) {
805 "Error loading file '" + SummaryFile +
"': ");
808 std::unique_ptr<ModuleSummaryIndex> Index = std::move(*IndexPtrOrErr);
819 for (
auto &
I : *Index) {
820 for (
auto &S :
I.second.SummaryList) {
829 errs() <<
"Error renaming module\n";
843 "Error importing module: ");
852 class FunctionImportLegacyPass :
public ModulePass {
858 StringRef getPassName()
const override {
return "Function Importing"; }
862 bool runOnModule(
Module &M)
override {
881 "Summary Based Function Import",
false,
false)
885 return new FunctionImportLegacyPass();
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time...
Pass interface - Implemented by all 'passes'.
void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true) const
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
void computeDeadSymbols(ModuleSummaryIndex &Index, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols)
Compute all the symbols that are "dead": i.e these that can't be reached in the graph from any of t...
void push_back(const T &Elt)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
STATISTIC(NumFunctions,"Total number of functions")
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
A Module instance is used to store all the information related to an LLVM module. ...
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner)
Log all errors (if any) in E to OS.
static MDString * get(LLVMContext &Context, StringRef Str)
Implements a dense probed hash-table based set.
bool withGlobalValueDeadStripping() const
static cl::opt< float > ImportHotInstrFactor("import-hot-evolution-factor", cl::init(1.0), cl::Hidden, cl::value_desc("x"), cl::desc("As we import functions called from hot callsite, multiply the ""`import-instr-limit` threshold by this factor ""before processing newly imported functions"))
Externally visible function.
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted)...
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
Error takeError()
Take ownership of the stored error.
void reserve(size_type N)
size_type size() const
Determine the number of elements in the SetVector.
static std::unique_ptr< Module > loadFile(const std::string &FileName, LLVMContext &Context)
static bool isLocalLinkage(LinkageTypes Linkage)
StringRef getName() const
Return a constant reference to the value's name.
Error move(std::unique_ptr< Module > Src, ArrayRef< GlobalValue * > ValuesToLink, std::function< void(GlobalValue &GV, ValueAdder Add)> AddLazyFor, bool IsPerformingImport)
Move in the provide values in ValuesToLink from Src.
static cl::opt< unsigned > ImportInstrLimit("import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"), cl::desc("Only import functions with less than N instructions"))
Limit on instruction count of imported functions.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const GlobalObject * getBaseObject() const
Tagged union holding either a T or a Error.
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
LLVM_NODISCARD bool empty() const
static void CollectAsmSymbols(const Module &M, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module...
static cl::opt< std::string > OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-"))
unsigned instCount() const
Get the instruction count recorded for this function.
bool insert(const value_type &X)
Insert a new element into the SetVector.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Class to hold module path string table and global value map, and encapsulate methods for operating on...
StringRef modulePath() const
Get the path to the module containing this function.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
bool isWeakForLinker() const
iterator find(const_arg_type_t< KeyT > Val)
void collectDefinedFunctionsForModule(StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
Collect for the given module the list of function it defines (GUID -> Summary).
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
initializer< Ty > init(const Ty &Val)
static cl::opt< float > ImportHotMultiplier("import-hot-multiplier", cl::init(3.0), cl::Hidden, cl::value_desc("x"), cl::desc("Multiply the `import-instr-limit` threshold for hot callsites"))
A set of analyses that are preserved following a run of a transformation pass.
void gatherImportedSummariesForModule(StringRef ModulePath, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, const FunctionImporter::ImportMapTy &ImportList, std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex)
Compute the set of summaries needed for a ThinLTO backend compilation of ModulePath.
Import information from summary.
This is an important class for using LLVM in a threaded context.
Pass * createFunctionImportPass()
This pass performs iterative function importing from other modules.
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
INITIALIZE_PASS(FunctionImportLegacyPass,"function-import","Summary Based Function Import", false, false) namespace llvm
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
Function and variable summary information to aid decisions and implementation of importing.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Error materialize()
Make sure this GlobalValue is fully read.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
std::pair< typename base::iterator, bool > insert(StringRef Key)
static cl::opt< float > ImportCriticalMultiplier("import-critical-multiplier", cl::init(100.0), cl::Hidden, cl::value_desc("x"), cl::desc("Multiply the `import-instr-limit` threshold for critical callsites"))
Struct that holds a reference to a particular GUID in a global value summary.
std::unique_ptr< Module > getLazyIRFileModule(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context, bool ShouldLazyLoadMetadata=false)
If the given file holds a bitcode image, return a Module for it which does lazy deserialization of fu...
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e...
static cl::opt< bool > EnableImportMetadata("enable-import-metadata", cl::init(true), cl::Hidden, cl::desc("Enable import metadata like 'thinlto_src_module'"))
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
LLVM_NODISCARD T pop_back_val()
static bool doImportingForModule(Module &M)
std::error_code EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const FunctionImporter::ImportMapTy &ModuleImports)
Emit into OutputFilename the files module ModulePath will import from.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path, bool IgnoreEmptyThinLTOIndexFile=false)
Parse the module summary index out of an IR file and return the module summary index object if found...
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
static cl::opt< float > ImportColdMultiplier("import-cold-multiplier", cl::init(0), cl::Hidden, cl::value_desc("N"), cl::desc("Multiply the `import-instr-limit` threshold for cold callsites"))
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
static cl::opt< bool > ComputeDead("compute-dead", cl::init(true), cl::Hidden, cl::desc("Compute dead symbols"))
llvm_unreachable("Unknown RegBank!")
Expected< bool > importFunctions(Module &M, const ImportMapTy &ImportList)
Import functions in Module M based on the supplied import list.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static std::vector< std::string > Flags
void ComputeCrossModuleImport(const ModuleSummaryIndex &Index, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, StringMap< FunctionImporter::ImportMapTy > &ImportLists, StringMap< FunctionImporter::ExportSetTy > &ExportLists)
Compute all the imports and exports for every module in the Index.
void emplace_back(ArgTypes &&...Args)
A raw_ostream that writes to a file descriptor.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
static cl::opt< bool > PrintImports("print-imports", cl::init(false), cl::Hidden, cl::desc("Print imported functions"))
bool hasLinkOnceODRLinkage() const
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void thinLTOInternalizeModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Internalize TheModule based on the information recorded in the summaries during global summary-based ...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
const std::string & getSourceFileName() const
Get the module's original source file name.
void thinLTOResolveWeakForLinkerModule(Module &TheModule, const GVSummaryMapTy &DefinedGlobals)
Resolve WeakForLinker values in TheModule based on the information recorded in the summaries during g...
Function summary information to aid decisions and implementation of importing.
GlobalValue::GUID getGUID() const
void ComputeCrossModuleImportForModule(StringRef ModulePath, const ModuleSummaryIndex &Index, FunctionImporter::ImportMapTy &ImportList)
Compute all the imports for the given module using the Index.
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
static cl::opt< std::string > SummaryFile("summary-file", cl::desc("The summary file to use for function importing."))
Summary file to use for function importing when using -function-import from the command line...
ArrayRef< T > getArrayRef() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::function< void(GlobalValue &)> ValueAdder
static cl::opt< float > ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7), cl::Hidden, cl::value_desc("x"), cl::desc("As we import functions, multiply the ""`import-instr-limit` threshold by this factor ""before processing newly imported functions"))
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, SetVector< GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
The function importer is automatically importing function from other modules based on the provided su...
A vector that has set insertion semantics.
Lightweight error class with error context and mandatory checking.
StringSet - A wrapper for StringMap that provides set-like functionality.
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
bool internalizeModule(Module &TheModule, std::function< bool(const GlobalValue &)> MustPreserveGV, CallGraph *CG=nullptr)
Helper function to internalize functions and variables in a Module.
LLVMContext & getContext() const
Get the global data context.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...