45 using namespace object;
47 #define DEBUG_TYPE "lto"
56 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
65 Hasher.
update(LLVM_VERSION_STRING);
66 #ifdef HAVE_LLVM_REVISION
67 Hasher.
update(LLVM_REVISION);
75 auto AddUnsigned = [&](
unsigned I) {
106 for (
auto F : ExportList)
111 for (
auto &Entry : ImportList) {
117 for (
auto &Entry : ResolvedODR) {
126 for (
auto &GS : DefinedGlobals) {
135 Hasher.
update(FileOrErr.get()->getBuffer());
148 for (
auto &S : GVSummaryList) {
160 if (isPrevailing(GUID, S.get())) {
166 else if (!isa<AliasSummary>(S.get()) &&
167 !GlobalInvolvedWithAlias.
count(S.get()) &&
171 if (S->linkage() != OriginalLinkage)
172 recordNewLinkage(S->modulePath(), GUID, S->linkage());
192 for (
auto &
I : Index)
193 for (
auto &S :
I.second)
194 if (
auto AS = dyn_cast<AliasSummary>(S.get()))
195 GlobalInvolvedWithAlias.
insert(&AS->getAliasee());
197 for (
auto &
I : Index)
199 isPrevailing, recordNewLinkage);
205 for (
auto &S : GVSummaryList) {
206 if (isExported(S->modulePath(), GUID)) {
219 for (
auto &
I : Index)
225 std::unique_ptr<Module>
Mod;
245 return BMsOrErr.takeError();
247 if (BMsOrErr->empty())
248 return make_error<StringError>(
"Bitcode file does not contain any modules",
253 for (
auto BM : *BMsOrErr) {
255 BM.getLazyModule(File->Ctx,
true,
260 size_t SymBegin = File->SymTab.symbols().size();
261 File->SymTab.addModule(MOrErr->
get());
262 size_t SymEnd = File->SymTab.symbols().size();
264 for (
const auto &
C : (*MOrErr)->getComdatSymbolTable()) {
265 auto P = File->ComdatMap.insert(
266 std::make_pair(&
C.second, File->Comdats.size()));
269 File->Comdats.push_back(
C.first());
272 File->Mods.push_back({BM, std::move(*MOrErr), SymBegin, SymEnd});
275 return std::move(File);
283 return make_error<StringError>(
"Unable to determine comdat of alias!",
286 auto I =
File->ComdatMap.find(
C);
294 return Mods[0].BM.getModuleIdentifier();
298 return Mods[0].Mod->getSourceFileName();
302 InputFile::module_symbols(InputModule &IM) {
308 LTO::RegularLTOState::RegularLTOState(
unsigned ParallelCodeGenParallelismLevel,
310 : ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel),
313 LTO::ThinLTOState::ThinLTOState(
ThinBackend Backend) : Backend(Backend) {
320 unsigned ParallelCodeGenParallelismLevel)
321 : Conf(std::move(Conf)),
322 RegularLTO(ParallelCodeGenParallelismLevel, this->Conf),
323 ThinLTO(std::move(Backend)) {}
332 GlobalValue *GV = Sym.isGV() ? Sym.getGV() :
nullptr;
334 auto &GlobalRes = GlobalResolutions[Sym.
getName()];
338 GlobalRes.IRName = GV->
getName();
345 GlobalRes.Partition != Partition)) {
346 GlobalRes.Partition = GlobalResolution::External;
349 GlobalRes.Partition = Partition;
353 GlobalRes.VisibleOutsideThinLTO |=
361 auto ResI = Res.
begin();
366 OS <<
"-r=" << Path <<
',' << Sym.
getName() <<
',';
369 if (Res.FinalDefinitionInLinkageUnit)
371 if (Res.VisibleToRegularObj)
380 assert(!CalledGetMaxTasks);
387 if (
Error Err = addModule(*Input, IM, ResI, Res.
end()))
401 return make_error<StringError>(
"input module has no datalayout",
410 if (!HasThinLTOSummary)
413 if (*HasThinLTOSummary)
414 return addThinLTO(IM.
BM, M, Input.module_symbols(IM), ResI, ResE);
416 return addRegularLTO(IM.
BM, ResI, ResE);
422 if (!RegularLTO.CombinedModule) {
423 RegularLTO.CombinedModule =
424 llvm::make_unique<Module>(
"ld-temp.o", RegularLTO.Ctx);
425 RegularLTO.Mover = llvm::make_unique<IRMover>(*RegularLTO.CombinedModule);
444 std::vector<GlobalValue *> Keep;
457 addSymbolToGlobalRes(Used, Sym, Res, 0);
481 auto &CommonRes = RegularLTO.Commons[Sym.getGV()->
getName()];
482 CommonRes.Size = std::max(CommonRes.Size, Sym.
getCommonSize());
490 return RegularLTO.Mover->move(std::move(*MOrErr), Keep,
509 ThinLTO.CombinedIndex.mergeFrom(std::move(*SummaryOrErr),
510 ThinLTO.ModuleMap.size());
515 addSymbolToGlobalRes(Used, Sym, Res, ThinLTO.ModuleMap.size() + 1);
518 ThinLTO.PrevailingModuleForGUID[Sym.getGV()->
getGUID()] =
523 return make_error<StringError>(
524 "Expected at most one ThinLTO module per bitcode file",
530 unsigned LTO::getMaxTasks()
const {
531 CalledGetMaxTasks =
true;
532 return RegularLTO.ParallelCodeGenParallelismLevel + ThinLTO.ModuleMap.size();
539 bool HasRegularLTO = RegularLTO.CombinedModule !=
nullptr;
542 if (
auto E = runRegularLTO(AddStream))
544 return runThinLTO(AddStream, Cache, HasRegularLTO);
550 const DataLayout &DL = RegularLTO.CombinedModule->getDataLayout();
551 for (
auto &
I : RegularLTO.Commons) {
552 if (!
I.second.Prevailing)
555 GlobalVariable *OldGV = RegularLTO.CombinedModule->getNamedGlobal(
I.first);
564 auto *GV =
new GlobalVariable(*RegularLTO.CombinedModule, Ty,
false,
567 GV->setAlignment(
I.second.Align);
577 if (Conf.PreOptModuleHook &&
578 !Conf.PreOptModuleHook(0, *RegularLTO.CombinedModule))
581 if (!Conf.CodeGenOnly) {
582 for (
const auto &R : GlobalResolutions) {
583 if (R.second.IRName.empty())
585 if (R.second.Partition != 0 &&
586 R.second.Partition != GlobalResolution::External)
590 RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
596 if (R.second.Partition == 0)
600 if (Conf.PostInternalizeModuleHook &&
601 !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))
604 return backend(Conf, AddStream, RegularLTO.ParallelCodeGenParallelismLevel,
605 std::move(RegularLTO.CombinedModule));
618 : Conf(Conf), CombinedIndex(CombinedIndex),
619 ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries) {}
626 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
641 InProcessThinBackend(
643 unsigned ThinLTOParallelismLevel,
647 BackendThreadPool(ThinLTOParallelismLevel),
648 AddStream(std::move(AddStream)), Cache(std::move(Cache)) {}
650 Error runThinLTOBackendThread(
655 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
664 return thinBackend(Conf, Task, AddStream, **MOrErr, CombinedIndex,
665 ImportList, DefinedGlobals, ModuleMap);
675 return RunThinBackend(AddStream);
679 computeCacheKey(Key, Conf, CombinedIndex, ModuleID, ImportList, ExportList,
680 ResolvedODR, DefinedGlobals);
682 return RunThinBackend(CacheAddStream);
691 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
694 assert(ModuleToDefinedGVSummaries.count(ModulePath));
696 ModuleToDefinedGVSummaries.find(ModulePath)->second;
697 BackendThreadPool.async(
701 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>
705 Error E = runThinLTOBackendThread(
706 AddStream, Cache, Task, BM, CombinedIndex, ImportList,
707 ExportList, ResolvedODR, DefinedGlobals, ModuleMap);
709 std::unique_lock<std::mutex>
L(ErrMu);
711 Err =
joinErrors(std::move(*Err), std::move(E));
716 BM, std::ref(CombinedIndex), std::ref(ImportList),
717 std::ref(ExportList), std::ref(ResolvedODR), std::ref(DefinedGlobals),
718 std::ref(ModuleMap));
722 Error wait()
override {
723 BackendThreadPool.wait();
725 return std::move(*Err);
736 return llvm::make_unique<InProcessThinBackend>(
737 Conf, CombinedIndex, ParallelismLevel, ModuleToDefinedGVSummaries,
746 const std::string &OldPrefix,
747 const std::string &NewPrefix) {
748 if (OldPrefix.empty() && NewPrefix.empty())
753 if (!ParentPath.
empty()) {
756 llvm::errs() <<
"warning: could not create directory '" << ParentPath
757 <<
"': " << EC.message() <<
'\n';
759 return NewPath.
str();
764 std::string OldPrefix, NewPrefix;
765 bool ShouldEmitImportsFiles;
767 std::string LinkedObjectsFileName;
768 std::unique_ptr<llvm::raw_fd_ostream> LinkedObjectsFile;
771 WriteIndexesThinBackend(
774 std::string OldPrefix, std::string NewPrefix,
bool ShouldEmitImportsFiles,
775 std::string LinkedObjectsFileName)
777 OldPrefix(OldPrefix), NewPrefix(NewPrefix),
778 ShouldEmitImportsFiles(ShouldEmitImportsFiles),
779 LinkedObjectsFileName(LinkedObjectsFileName) {}
785 const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
788 std::string NewModulePath =
792 if (!LinkedObjectsFileName.empty()) {
793 if (!LinkedObjectsFile) {
794 LinkedObjectsFile = llvm::make_unique<raw_fd_ostream>(
799 *LinkedObjectsFile << NewModulePath <<
'\n';
802 std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
804 ImportList, ModuleToSummariesForIndex);
812 if (ShouldEmitImportsFiles)
823 std::string NewPrefix,
824 bool ShouldEmitImportsFiles,
825 std::string LinkedObjectsFile) {
829 return llvm::make_unique<WriteIndexesThinBackend>(
830 Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix,
831 ShouldEmitImportsFiles, LinkedObjectsFile);
836 bool HasRegularLTO) {
837 if (ThinLTO.ModuleMap.empty())
840 if (Conf.CombinedIndexHook && !Conf.CombinedIndexHook(ThinLTO.CombinedIndex))
846 ModuleToDefinedGVSummaries(ThinLTO.ModuleMap.size());
847 ThinLTO.CombinedIndex.collectDefinedGVSummariesPerModule(
848 ModuleToDefinedGVSummaries);
856 for (
auto &Mod : ThinLTO.ModuleMap)
857 if (!ModuleToDefinedGVSummaries.count(Mod.first))
862 for (
auto &Res : GlobalResolutions) {
863 if (Res.second.VisibleOutsideThinLTO &&
866 !Res.second.IRName.empty())
874 ThinLTO.ModuleMap.size());
876 ThinLTO.ModuleMap.size());
879 if (Conf.OptLevel > 0) {
881 ImportLists, ExportLists, &DeadSymbols);
883 std::set<GlobalValue::GUID> ExportedGUIDs;
884 for (
auto &Res : GlobalResolutions) {
886 if (Res.second.Partition != GlobalResolution::External)
891 if (Res.second.IRName.empty())
895 if (!DeadSymbols.count(GUID))
901 return ThinLTO.PrevailingModuleForGUID[GUID] == S->modulePath();
904 const auto &ExportList = ExportLists.find(ModuleIdentifier);
905 return (ExportList != ExportLists.end() &&
906 ExportList->second.count(GUID)) ||
907 ExportedGUIDs.count(GUID);
911 auto recordNewLinkage = [&](
StringRef ModuleIdentifier,
914 ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
921 std::unique_ptr<ThinBackendProc> BackendProc =
922 ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
929 HasRegularLTO ? RegularLTO.ParallelCodeGenParallelismLevel : 0;
930 for (
auto &Mod : ThinLTO.ModuleMap) {
931 if (
Error E = BackendProc->start(Task, Mod.second, ImportLists[Mod.first],
932 ExportLists[Mod.first],
933 ResolvedODR[Mod.first], ThinLTO.ModuleMap))
938 return BackendProc->wait();
std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
A parsed version of the target data layout string in and methods for querying it. ...
std::error_code getError() const
LinkageTypes getLinkage() const
Represents either an error or a value T.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class defines the interface to the ThinLTO backend.
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
unsigned Prevailing
The linker has chosen this definition of the symbol.
CodeGenOpt::Level CGOptLevel
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
unsigned heavyweight_hardware_concurrency()
Get the amount of currency to use for tasks requiring significant memory or other resources...
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallPtrSetImpl< GlobalValue * > &Set, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
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.
Same, but only replaced by something equivalent.
Implements a dense probed hash-table based set.
std::string OverrideTriple
Setting this field will replace target triples in input files with this triple.
Available for inspection, not emission.
unsigned DataSections
Emit data into separate sections.
static ConstantAggregateZero * get(Type *Ty)
Type * getValueType() const
bool hasAppendingLinkage() const
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::unique_ptr< raw_ostream > ResolutionFile
If this field is set, LTO will write input file paths and symbol resolutions here in llvm-lto2 comman...
An efficient, type-erasing, non-owning reference to a callable.
Expected< bool > hasSummary()
Check if the given bitcode buffer contains a summary block.
Expected< std::unique_ptr< ModuleSummaryIndex > > getSummary()
Parse the specified bitcode buffer, returning the module summary index.
Externally visible function.
The resolution for a symbol.
This class implements a map that also provides access to all stored values in a deterministic order...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
const StringMap< GVSummaryMapTy > & ModuleToDefinedGVSummaries
A class that wrap the SHA1 algorithm.
Error takeError()
Take ownership of the stored error.
void setAlignment(unsigned Align)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
static bool isLocalLinkage(LinkageTypes Linkage)
static bool isLinkOnceLinkage(LinkageTypes Linkage)
StringRef getName() const
Return a constant reference to the value's name.
std::function< std::unique_ptr< NativeObjectStream >unsigned Task)> AddStreamFn
This type defines the callback to add a native object that is generated on the fly.
std::unordered_set< GlobalValue::GUID > ExportSetTy
The set contains an entry for every global value the module exports.
Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.
Represents a module in a bitcode file.
virtual Error start(unsigned Task, BitcodeModule BM, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > &ResolvedODR, MapVector< StringRef, BitcodeModule > &ModuleMap)=0
std::vector< std::string > MAttrs
ModuleSummaryIndex & CombinedIndex
void setName(const Twine &Name)
Change the name of the value.
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.
StringRef result()
Return a reference to the current raw 160-bits SHA1 for the digested data since the last call to init...
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
void addModule(Module *M)
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
static std::string toHex(StringRef Input)
Convert buffer Input to its hexadecimal representation.
Class to represent array types.
std::string SampleProfile
Sample PGO profile path.
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
unsigned FunctionSections
Emit functions into separate sections.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
A ThreadPool for asynchronous parallel execution on a defined number of threads.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static ErrorOr< MemoryBufferRef > findBitcodeInMemBuffer(MemoryBufferRef Object)
Finds and returns bitcode in the given memory buffer (which may be either a bitcode file or a native ...
void takeName(Value *V)
Transfer the name from V to this value.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
void update(ArrayRef< uint8_t > Data)
Digest more data.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isWeakForLinker() const
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Error add(std::unique_ptr< InputFile > Obj, ArrayRef< SymbolResolution > Res)
Add an input file to the LTO link, using the provided symbol resolutions.
DebuggerKind DebuggerTuning
Which debugger to tune for.
Same, but only replaced by something equivalent.
std::function< AddStreamFn(unsigned Task, StringRef Key)> NativeObjectCache
This is the type of a native object cache.
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.
static bool isWeakODRLinkage(LinkageTypes Linkage)
const Comdat * getComdat() const
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
ThinBackend createWriteIndexesThinBackend(std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, std::string LinkedObjectsFile)
This ThinBackend writes individual module indexes to files, instead of running the individual backend...
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.
ThinBackendProc(Config &Conf, ModuleSummaryIndex &CombinedIndex, const StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries)
void replace_path_prefix(SmallVectorImpl< char > &Path, const StringRef &OldPrefix, const StringRef &NewPrefix)
Replace matching path prefix with another path.
std::string DefaultTriple
Setting this field will replace unspecified target triples in input files with this triple...
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.
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 LinkageTypes getWeakLinkage(bool ODR)
static void writeToResolutionFile(raw_ostream &OS, InputFile *Input, ArrayRef< SymbolResolution > Res)
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
Emplace a new element for the specified key into the map if the key isn't already in the map...
Error thinBackend(Config &C, unsigned Task, AddStreamFn AddStream, Module &M, ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > &ModuleMap)
Runs a ThinLTO backend.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static ErrorSuccess success()
Create a success value.
bool hasGlobalUnnamedAddr() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
std::function< std::unique_ptr< ThinBackendProc > Config &C, ModuleSummaryIndex &CombinedIndex, StringMap< GVSummaryMapTy > &ModuleToDefinedGVSummaries, AddStreamFn AddStream, NativeObjectCache Cache)> ThinBackend
A ThinBackend defines what happens after the thin-link phase during ThinLTO.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
static void computeCacheKey(SmallString< 40 > &Key, const Config &Conf, const ModuleSummaryIndex &Index, StringRef ModuleID, const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map< GlobalValue::GUID, GlobalValue::LinkageTypes > &ResolvedODR, const GVSummaryMapTy &DefinedGlobals)
Keep one copy of function when linking (inline)
static void thinLTOInternalizeAndPromoteGUID(GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID, function_ref< bool(StringRef, GlobalValue::GUID)> isExported)
virtual ~ThinBackendProc()
reference get()
Returns a reference to the stored T value.
std::error_code EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const FunctionImporter::ImportMapTy &ModuleImports)
Emit into OutputFilename the files module ModulePath will import from.
static void thinLTOResolveWeakForLinkerGUID(GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID, DenseSet< GlobalValueSummary * > &GlobalInvolvedWithAlias, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref< void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage)
void setLinkage(LinkageTypes LT)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
StringRef getModuleIdentifier() const
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
StringRef parent_path(StringRef path)
Get parent path.
StringRef str() const
Explicit conversion to StringRef.
LinkageTypes
An enumeration for the kinds of linkage for global values.
std::string OptPipeline
If this field is set, the set of passes run in the middle-end optimizer will be the one specified by ...
void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
const GlobalObject * getBaseObject() const
unsigned RelaxELFRelocations
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ThinBackend createInProcessThinBackend(unsigned ParallelismLevel)
This ThinBackend runs the individual backend jobs in-process.
PointerType * getType() const
Global values are always pointers.
std::map< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module...
A raw_ostream that writes to a file descriptor.
LTO(Config Conf, ThinBackend Backend=nullptr, unsigned ParallelCodeGenParallelismLevel=1)
Create an LTO object.
void setUnnamedAddr(UnnamedAddr Val)
size_type count(const ValueT &V) const
Return 1 if the specified key is in the set, 0 otherwise.
void thinLTOResolveWeakForLinkerInIndex(ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref< void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage)
Resolve Weak and LinkOnce values in the Index.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
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...
Error joinErrors(Error E1, Error E2)
Concatenate errors.
Error backend(Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr< Module > M)
Runs a regular LTO backend.
ArrayRef< Symbol > symbols() const
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
void setTargetTriple(StringRef T)
Set the target triple.
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
CodeModel::Model CodeModel
unsigned VisibleToRegularObj
The definition of this symbol is visible outside of the LTO unit.
bool hasLocalLinkage() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::function< void(GlobalValue &)> ValueAdder
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting)
Read the bitcode module and prepare for lazy deserialization of function bodies.
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context)
Read the entire bitcode module and return it.
iterator_range< global_iterator > globals()
A derived class of LLVMContext that initializes itself according to a given Config object...
StringRef - Represent a constant reference to a string, i.e.
const std::string & getDataLayoutStr() const
Get the data layout string for the module's target platform.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
llvm::Error materializeMetadata()
static IntegerType * getInt8Ty(LLVMContext &C)
std::string getThinLTOOutputFile(const std::string &Path, const std::string &OldPrefix, const std::string &NewPrefix)
Given the original Path to an output file, replace any path prefix matching OldPrefix with NewPrefix...
void thinLTOInternalizeAndPromoteInIndex(ModuleSummaryIndex &Index, function_ref< bool(StringRef, GlobalValue::GUID)> isExported)
Update the linkages in the given Index to mark exported values as external and non-exported values as...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...