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"));
70 cl::desc(
"Multiply the `import-instr-limit` threshold for cold callsites"));
73 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 =
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);
151 if (Summary->notEligibleToImport())
156 if (It == CalleeSummaryList.end())
159 return cast<GlobalValueSummary>(It->get());
168 if (CalleeSummaryList == Index.
end())
170 return selectCallee(Index, CalleeSummaryList->second, Threshold);
179 static void computeImportForFunction(
181 const unsigned Threshold,
const GVSummaryMapTy &DefinedGVSummaries,
185 for (
auto &Edge : Summary.
calls()) {
186 auto GUID = Edge.first.getGUID();
187 DEBUG(
dbgs() <<
" edge -> " << GUID <<
" Threshold:" << Threshold <<
"\n");
189 if (DefinedGVSummaries.count(GUID)) {
190 DEBUG(
dbgs() <<
"ignored! Target already in destination module.\n");
202 const auto NewThreshold =
203 Threshold * GetBonusMultiplier(Edge.second.Hotness);
205 auto *CalleeSummary = selectCallee(GUID, NewThreshold, Index);
206 if (!CalleeSummary) {
207 DEBUG(
dbgs() <<
"ignored! No qualifying callee with summary found.\n");
211 const FunctionSummary *ResolvedCalleeSummary;
212 if (isa<AliasSummary>(CalleeSummary)) {
213 ResolvedCalleeSummary = cast<FunctionSummary>(
214 &cast<AliasSummary>(CalleeSummary)->getAliasee());
217 "Unexpected alias to a non-linkonceODR in import list");
219 ResolvedCalleeSummary = cast<FunctionSummary>(CalleeSummary);
222 "selectCallee() didn't honor the threshold");
224 auto GetAdjustedThreshold = [](
unsigned Threshold,
bool IsHotCallsite) {
234 const auto AdjThreshold = GetAdjustedThreshold(Threshold, IsHotCallsite);
236 auto ExportModulePath = ResolvedCalleeSummary->
modulePath();
237 auto &ProcessedThreshold = ImportList[ExportModulePath][GUID];
241 if (ProcessedThreshold && ProcessedThreshold >= AdjThreshold) {
242 DEBUG(
dbgs() <<
"ignored! Target was already seen with Threshold "
243 << ProcessedThreshold <<
"\n");
246 bool PreviouslyImported = ProcessedThreshold != 0;
248 ProcessedThreshold = AdjThreshold;
252 auto &ExportList = (*ExportLists)[ExportModulePath];
253 ExportList.insert(GUID);
254 if (!PreviouslyImported) {
261 for (
auto &Edge : ResolvedCalleeSummary->
calls()) {
262 auto CalleeGUID = Edge.first.getGUID();
263 ExportList.insert(CalleeGUID);
265 for (
auto &Ref : ResolvedCalleeSummary->
refs()) {
266 auto GUID = Ref.getGUID();
267 ExportList.insert(GUID);
273 Worklist.
emplace_back(ResolvedCalleeSummary, AdjThreshold, GUID);
280 static void ComputeImportForModule(
291 for (
auto &GVSummary : DefinedGVSummaries) {
292 if (DeadSymbols && DeadSymbols->count(GVSummary.first)) {
293 DEBUG(
dbgs() <<
"Ignores Dead GUID: " << GVSummary.first <<
"\n");
296 auto *Summary = GVSummary.second;
297 if (
auto *AS = dyn_cast<AliasSummary>(Summary))
298 Summary = &AS->getAliasee();
299 auto *FuncSummary =
dyn_cast<FunctionSummary>(Summary);
303 DEBUG(
dbgs() <<
"Initalize import for " << GVSummary.first <<
"\n");
305 DefinedGVSummaries, Worklist, ImportList,
310 while (!Worklist.
empty()) {
312 auto *Summary = std::get<0>(FuncInfo);
313 auto Threshold = std::get<1>(FuncInfo);
314 auto GUID = std::get<2>(FuncInfo);
318 auto ExportModulePath = Summary->
modulePath();
319 auto &LatestProcessedThreshold = ImportList[ExportModulePath][GUID];
320 if (LatestProcessedThreshold > Threshold)
323 computeImportForFunction(*Summary, Index, Threshold, DefinedGVSummaries,
324 Worklist, ImportList, ExportLists);
338 for (
auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
339 auto &ImportList = ImportLists[DefinedGVSummaries.first()];
340 DEBUG(
dbgs() <<
"Computing import for Module '"
341 << DefinedGVSummaries.first() <<
"'\n");
342 ComputeImportForModule(DefinedGVSummaries.second, Index, ImportList,
343 &ExportLists, DeadSymbols);
351 for (
auto &ELI : ExportLists) {
352 const auto &DefinedGVSummaries =
353 ModuleToDefinedGVSummaries.lookup(ELI.first());
354 for (
auto EI = ELI.second.begin(); EI != ELI.second.end();) {
355 if (!DefinedGVSummaries.count(*EI))
356 EI = ELI.second.erase(EI);
363 DEBUG(
dbgs() <<
"Import/Export lists for " << ImportLists.
size()
365 for (
auto &ModuleImports : ImportLists) {
366 auto ModName = ModuleImports.first();
367 auto &Exports = ExportLists[ModName];
368 DEBUG(
dbgs() <<
"* Module " << ModName <<
" exports " << Exports.size()
369 <<
" functions. Imports from " << ModuleImports.second.size()
371 for (
auto &Src : ModuleImports.second) {
372 auto SrcModName = Src.first();
373 DEBUG(
dbgs() <<
" - " << Src.second.size() <<
" functions imported from "
374 << SrcModName <<
"\n");
391 DEBUG(
dbgs() <<
"Computing import for Module '" << ModulePath <<
"'\n");
392 ComputeImportForModule(FunctionSummaryMap, Index, ImportList);
395 DEBUG(
dbgs() <<
"* Module " << ModulePath <<
" imports from "
396 << ImportList.
size() <<
" modules.\n");
397 for (
auto &Src : ImportList) {
398 auto SrcModName = Src.first();
399 DEBUG(
dbgs() <<
" - " << Src.second.size() <<
" functions imported from "
400 << SrcModName <<
"\n");
410 if (GUIDPreservedSymbols.
empty())
416 for (
auto GUID : LiveSymbols) {
417 DEBUG(
dbgs() <<
"Live root: " << GUID <<
"\n");
421 for (
const auto &Entry : Index) {
424 [&](
const std::unique_ptr<llvm::GlobalValueSummary> &Summary) {
425 return Summary->liveRoot();
429 DEBUG(
dbgs() <<
"Live root (summary): " << Entry.first <<
"\n");
433 while (!Worklist.
empty()) {
436 if (It == Index.
end()) {
437 DEBUG(
dbgs() <<
"Not in index: " << GUID <<
"\n");
442 for (
auto &Summary : It->second) {
443 for (
auto Ref : Summary->
refs()) {
444 auto RefGUID = Ref.getGUID();
445 if (LiveSymbols.insert(RefGUID).second) {
446 DEBUG(
dbgs() <<
"Marking live (ref): " << RefGUID <<
"\n");
450 if (
auto *FS = dyn_cast<FunctionSummary>(Summary.get())) {
451 for (
auto Call :
FS->calls()) {
452 auto CallGUID =
Call.first.getGUID();
453 if (LiveSymbols.insert(CallGUID).second) {
454 DEBUG(
dbgs() <<
"Marking live (call): " << CallGUID <<
"\n");
459 if (
auto *AS = dyn_cast<AliasSummary>(Summary.get())) {
460 auto AliaseeGUID = AS->getAliasee().getOriginalName();
461 if (LiveSymbols.insert(AliaseeGUID).second) {
462 DEBUG(
dbgs() <<
"Marking live (alias): " << AliaseeGUID <<
"\n");
471 for (
auto &Entry : Index) {
472 auto GUID = Entry.first;
473 if (!LiveSymbols.count(GUID)) {
474 DEBUG(
dbgs() <<
"Marking dead: " << GUID <<
"\n");
475 DeadSymbols.insert(GUID);
478 DEBUG(
dbgs() << LiveSymbols.size() <<
" symbols Live, and "
479 << DeadSymbols.size() <<
" symbols Dead \n");
480 NumDeadSymbols += DeadSymbols.size();
481 NumLiveSymbols += LiveSymbols.size();
491 std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
493 ModuleToSummariesForIndex[ModulePath] =
494 ModuleToDefinedGVSummaries.
lookup(ModulePath);
496 for (
auto &ILI : ImportList) {
497 auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()];
498 const auto &DefinedGVSummaries =
499 ModuleToDefinedGVSummaries.
lookup(ILI.first());
500 for (
auto &GI : ILI.second) {
501 const auto &
DS = DefinedGVSummaries.find(GI.first);
502 assert(
DS != DefinedGVSummaries.end() &&
503 "Expected a defined summary for imported global value");
504 SummariesForIndex[GI.first] =
DS->second;
517 for (
auto &ILI : ModuleImports)
518 ImportsOS << ILI.first() <<
"\n";
519 return std::error_code();
526 if (!GlobalValue::isWeakForLinker(GV.getLinkage()))
529 const auto &GS = DefinedGlobals.find(GV.getGUID());
530 if (GS == DefinedGlobals.end())
532 auto NewLinkage = GS->second->linkage();
533 if (NewLinkage == GV.getLinkage())
535 DEBUG(
dbgs() <<
"ODR fixing up linkage for `" << GV.getName() <<
"` from "
536 << GV.getLinkage() <<
" to " << NewLinkage <<
"\n");
537 GV.setLinkage(NewLinkage);
541 auto *GO = dyn_cast_or_null<GlobalObject>(&GV);
542 if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) {
543 assert(GO->hasAvailableExternallyLinkage() &&
544 "Expected comdat on definition (possibly available external)");
545 GO->setComdat(
nullptr);
550 for (
auto &GV : TheModule)
552 for (
auto &GV : TheModule.globals())
554 for (
auto &GV : TheModule.aliases())
564 ModuleSymbolTable::CollectAsmSymbols(
567 if (
Flags & object::BasicSymbolRef::SF_Undefined)
568 AsmUndefinedRefs.
insert(Name);
573 auto MustPreserveGV = [&](
const GlobalValue &GV) ->
bool {
575 if (AsmUndefinedRefs.
count(GV.getName()))
579 const auto &GS = DefinedGlobals.find(GV.getGUID());
581 if (GS == DefinedGlobals.end()) {
588 ModuleSummaryIndex::getOriginalNameBeforePromote(GV.getName());
589 std::string OrigId = GlobalValue::getGlobalIdentifier(
590 OrigName, GlobalValue::InternalLinkage,
592 const auto &GS = DefinedGlobals.find(GlobalValue::getGUID(OrigId));
593 if (GS == DefinedGlobals.end()) {
600 const auto &GS = DefinedGlobals.find(GlobalValue::getGUID(OrigName));
601 assert(GS != DefinedGlobals.end());
602 Linkage = GS->second->linkage();
604 Linkage = GS->second->linkage();
607 Linkage = GS->second->linkage();
608 return !GlobalValue::isLocalLinkage(Linkage);
621 bool ForceImportReferencedDiscardableSymbols) {
622 DEBUG(
dbgs() <<
"Starting import for Module "
624 unsigned ImportedCount = 0;
627 Linker TheLinker(DestModule);
629 std::set<StringRef> ModuleNameOrderedList;
630 for (
auto &FunctionsToImportPerModule : ImportList) {
631 ModuleNameOrderedList.insert(FunctionsToImportPerModule.first());
633 for (
auto &
Name : ModuleNameOrderedList) {
635 const auto &FunctionsToImportPerModule = ImportList.find(
Name);
636 assert(FunctionsToImportPerModule != ImportList.end());
639 return SrcModuleOrErr.takeError();
640 std::unique_ptr<Module> SrcModule = std::move(*SrcModuleOrErr);
646 if (
Error Err = SrcModule->materializeMetadata())
647 return std::move(Err);
649 auto &ImportGUIDs = FunctionsToImportPerModule->second;
655 auto GUID =
F.getGUID();
656 auto Import = ImportGUIDs.count(GUID);
657 DEBUG(
dbgs() << (
Import ?
"Is" :
"Not") <<
" importing function " << GUID
658 <<
" " <<
F.getName() <<
" from "
659 << SrcModule->getSourceFileName() <<
"\n");
661 if (
Error Err =
F.materialize())
662 return std::move(Err);
666 "thinlto_src_module",
670 SrcModule->getSourceFileName())}));
678 auto GUID = GV.getGUID();
679 auto Import = ImportGUIDs.count(GUID);
680 DEBUG(
dbgs() << (
Import ?
"Is" :
"Not") <<
" importing global " << GUID
681 <<
" " << GV.getName() <<
" from "
682 << SrcModule->getSourceFileName() <<
"\n");
684 if (
Error Err = GV.materialize())
685 return std::move(Err);
686 GlobalsToImport.
insert(&GV);
692 auto GUID = GA.getGUID();
693 auto Import = ImportGUIDs.count(GUID);
695 <<
" " << GA.getName() <<
" from "
696 << SrcModule->getSourceFileName() <<
"\n");
704 "Unexpected alias to a non-linkonceODR in import list");
706 if (!GlobalsToImport.
count(GO))
708 <<
" " << GO->
getName() <<
" from "
709 << SrcModule->getSourceFileName() <<
"\n");
712 return std::move(Err);
713 GlobalsToImport.
insert(GO);
714 if (
Error Err = GA.materialize())
715 return std::move(Err);
716 GlobalsToImport.
insert(&GA);
729 for (
const auto *GV : GlobalsToImport)
731 <<
" from " << SrcModule->getSourceFileName() <<
"\n";
736 if (!ForceImportReferencedDiscardableSymbols)
737 Flags |= Linker::Flags::DontForceLinkLinkonceODR;
739 if (TheLinker.
linkInModule(std::move(SrcModule), Flags, &GlobalsToImport))
742 ImportedCount += GlobalsToImport.
size();
743 NumImportedModules++;
746 NumImportedFunctions += ImportedCount;
748 DEBUG(
dbgs() <<
"Imported " << ImportedCount <<
" functions for Module "
750 return ImportedCount;
757 cl::desc(
"The summary file to use for function importing."));
760 if (SummaryFile.empty())
764 if (!IndexPtrOrErr) {
766 "Error loading file '" + SummaryFile +
"': ");
769 std::unique_ptr<ModuleSummaryIndex> Index = std::move(*IndexPtrOrErr);
780 for (
auto &
I : *Index) {
781 for (
auto &S :
I.second) {
790 errs() <<
"Error renaming module\n";
795 auto ModuleLoader = [&M](
StringRef Identifier) {
805 "Error importing module: ");
814 class FunctionImportLegacyPass :
public ModulePass {
820 StringRef getPassName()
const override {
return "Function Importing"; }
824 bool runOnModule(
Module &M)
override {
843 "Summary Based Function Import",
false,
false)
847 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 push_back(const T &Elt)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
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.
A Module instance is used to store all the information related to an LLVM module. ...
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.
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.
Error takeError()
Take ownership of the stored error.
void reserve(size_type N)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Expected< bool > importFunctions(Module &M, const ImportMapTy &ImportList, bool ForceImportReferencedDiscardableSymbols=false)
Import functions in Module M based on the supplied import list.
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.
struct fuzzer::@269 Flags
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...
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 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.
This class provides the core functionality of linking in LLVM.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
StringRef modulePath() const
Get the path to the module containing this function.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
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.
static cl::opt< bool > DontForceImportReferencedDiscardableSymbols("disable-force-link-odr", cl::init(false), cl::Hidden)
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.
This is an important class for using LLVM in a threaded context.
Pass * createFunctionImportPass()
This pass performs iterative function importing from other modules.
const const_gvsummary_iterator findGlobalValueSummaryList(StringRef ValueName) const
Get the list of global value summary objects for a given value name.
std::pair< iterator, bool > insert(const ValueT &V)
bool UpgradeDebugInfo(Module &M)
Check the debug info version number, if it is out-dated, drop the debug info.
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
INITIALIZE_PASS(FunctionImportLegacyPass,"function-import","Summary Based Function Import", false, false) namespace llvm
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.
void ComputeCrossModuleImport(const ModuleSummaryIndex &Index, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, StringMap< FunctionImporter::ImportMapTy > &ImportLists, StringMap< FunctionImporter::ExportSetTy > &ExportLists, const DenseSet< GlobalValue::GUID > *DeadSymbols=nullptr)
Compute all the imports and exports for every module in the Index.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
std::pair< typename base::iterator, bool > insert(StringRef Key)
Triple - Helper class for working with autoconf configuration names.
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path)
Parse the module summary index out of an IR file and return the module summary index object if found...
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
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...
Import typeid resolutions from summary and globals.
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.
static cl::opt< bool > EnableImportMetadata("enable-import-metadata", cl::init(true), cl::Hidden, cl::desc("Enable import metadata like 'thinlto_src_module'"))
LLVM_NODISCARD T pop_back_val()
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, DenseSet< const GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
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"...
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
LinkageTypes
An enumeration for the kinds of linkage for global values.
const GlobalObject * getBaseObject() const
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"))
static cl::opt< bool > ComputeDead("compute-dead", cl::init(true), cl::Hidden, cl::desc("Compute dead symbols"))
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
std::map< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module...
void emplace_back(ArgTypes &&...Args)
A raw_ostream that writes to a file descriptor.
size_type count(const ValueT &V) const
Return 1 if the specified key is in the set, 0 otherwise.
static cl::opt< bool > PrintImports("print-imports", cl::init(false), cl::Hidden, cl::desc("Print imported functions"))
DenseSet< GlobalValue::GUID > computeDeadSymbols(const 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...
bool hasLinkOnceODRLinkage() const
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void reserve(size_t Size)
Grow the DenseSet so that it can contain at least NumEntries items before resizing again...
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)
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.
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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"))
The function importer is automatically importing function from other modules based on the provided su...
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.
bool linkInModule(std::unique_ptr< Module > Src, unsigned Flags=Flags::None, DenseSet< const GlobalValue * > *GlobalsToImport=nullptr)
Link Src into the composite.
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...