LLVM: llvm::lto Namespace Reference (original) (raw)
| Classes | |
|---|---|
| struct | Config |
| LTO configuration. More... | |
| class | InputFile |
| An input file. More... | |
| class | LTO |
| This class implements a resolution-based interface to LLVM's LTO functionality. More... | |
| struct | LTOLLVMContext |
| A derived class of LLVMContext that initializes itself according to a given Config object. More... | |
| struct | LTOLLVMDiagnosticHandler |
| struct | SymbolResolution |
| The resolution for a symbol. More... | |
| struct | ThinBackend |
| This type defines the behavior following the thin-link phase during ThinLTO. More... | |
| class | ThinBackendProc |
| This class defines the interface to the ThinLTO backend. More... |
| Typedefs | |
|---|---|
| using | IndexWriteCallback = std::function<void(const std::string &)> |
| using | ImportsFilesContainer = llvm::SmallVectorstd::string |
| using | ThinBackendFunction |
| This callable defines the behavior of a ThinLTO backend after the thin-link phase. |
| Functions | |
|---|---|
| LLVM_ABI StringLiteral | getThinLTODefaultCPU (const Triple &TheTriple) |
| LLVM_ABI std::string | getThinLTOOutputFile (StringRef Path, StringRef OldPrefix, StringRef NewPrefix) |
| Given the original Path to an output file, replace any path prefix matching OldPrefix with NewPrefix. | |
| LLVM_ABI Expected< LLVMRemarkFileHandle > | setupLLVMOptimizationRemarks (LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, std::optional< uint64_t > RemarksHotnessThreshold=0, int Count=-1) |
| Setup optimization remarks. | |
| LLVM_ABI Expected< std::unique_ptr< ToolOutputFile > > | setupStatsFile (StringRef StatsFilename) |
| Setups the output file for saving statistics. | |
| LLVM_ABI std::vector< int > | generateModulesOrdering (ArrayRef< BitcodeModule * > R) |
| Produces a container ordering for optimal multi-threaded processing. | |
| LLVM_ABI ThinBackend | createInProcessThinBackend (ThreadPoolStrategy Parallelism, IndexWriteCallback OnWrite=nullptr, bool ShouldEmitIndexFiles=false, bool ShouldEmitImportsFiles=false) |
| This ThinBackend runs the individual backend jobs in-process. | |
| LLVM_ABI ThinBackend | createOutOfProcessThinBackend (ThreadPoolStrategy Parallelism, IndexWriteCallback OnWrite, bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles, StringRef LinkerOutputFile, StringRef Distributor, ArrayRef< StringRef > DistributorArgs, StringRef RemoteCompiler, ArrayRef< StringRef > RemoteCompilerPrependArgs, ArrayRef< StringRef > RemoteCompilerArgs, bool SaveTemps) |
| This ThinBackend generates the index shards and then runs the individual backend jobs via an external process. | |
| LLVM_ABI ThinBackend | createWriteIndexesThinBackend (ThreadPoolStrategy Parallelism, std::string OldPrefix, std::string NewPrefix, std::string NativeObjectPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite) |
| This ThinBackend writes individual module indexes to files, instead of running the individual backend jobs. | |
| LLVM_ABI bool | opt (const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary, const std::vector< uint8_t > &CmdArgs) |
| Runs middle-end LTO optimizations on Mod. | |
| LLVM_ABI Error | backend (const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &M, ModuleSummaryIndex &CombinedIndex) |
| Runs a regular LTO backend. | |
| LLVM_ABI Error | thinBackend (const Config &C, unsigned Task, AddStreamFn AddStream, Module &M, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > *ModuleMap, bool CodeGenOnly, AddStreamFn IRAddStream=nullptr, const std::vector< uint8_t > &CmdArgs=std::vector< uint8_t >()) |
| Runs a ThinLTO backend. | |
| LLVM_ABI Error | finalizeOptimizationRemarks (LLVMRemarkFileHandle DiagOutputFile) |
| LLVM_ABI BitcodeModule * | findThinLTOModule (MutableArrayRef< BitcodeModule > BMs) |
| Returns the BitcodeModule that is ThinLTO. | |
| LLVM_ABI Expected< BitcodeModule > | findThinLTOModule (MemoryBufferRef MBRef) |
| Variant of the above. | |
| LLVM_ABI bool | initImportList (const Module &M, const ModuleSummaryIndex &CombinedIndex, FunctionImporter::ImportMapTy &ImportList) |
| Distributed ThinLTO: collect the referenced modules based on module summary and initialize ImportList. |
◆ ImportsFilesContainer
◆ IndexWriteCallback
using llvm::lto::IndexWriteCallback = std::function<void(const std::string &)>
Definition at line 199 of file LTO.h.
◆ ThinBackendFunction
Initial value:
std::function<std::unique_ptr(
Class to hold module path string table and global value map, and encapsulate methods for operating on...
@ C
The default llvm calling convention, compatible with C.
std::function< Expected< std::unique_ptr< CachedFileStream > >( unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
This type represents a file cache system that manages caching of files.
This callable defines the behavior of a ThinLTO backend after the thin-link phase.
It accepts a configuration C, a combined module summary index CombinedIndex, a map of module identifiers to global variable summaries ModuleToDefinedGVSummaries, a function to add output streams AddStream, and a file cache Cache. It returns a unique pointer to a ThinBackendProc, which can be used to launch backends in parallel.
Definition at line 264 of file LTO.h.
◆ backend()
Runs a regular LTO backend.
The regular LTO backend can also act as the regular LTO phase of ThinLTO, which may need to access the combined index.
Definition at line 559 of file LTOBackend.cpp.
References llvm::CallingConv::C, createTargetMachine(), llvm::dbgs(), initAndLookupTarget(), LLVM_DEBUG, llvm::Mod, opt(), splitCodeGen(), llvm::Error::success(), and llvm::Expected< T >::takeError().
◆ createInProcessThinBackend()
This ThinBackend runs the individual backend jobs in-process.
The default value means to use one job per hardware core (not hyper-thread). OnWrite is callback which receives module identifier and notifies LTO user that index file for the module (and optionally imports file) was created. ShouldEmitIndexFiles being true will write sharded ThinLTO index files to the same path as the input module, with suffix ".thinlto.bc" ShouldEmitImportsFiles is true it also writes a list of imported files to a similar path with ".imports" appended instead.
Definition at line 1759 of file LTO.cpp.
◆ createOutOfProcessThinBackend()
| ThinBackend llvm::lto::createOutOfProcessThinBackend | ( | ThreadPoolStrategy | Parallelism, |
|---|---|---|---|
| lto::IndexWriteCallback | OnWrite, | ||
| bool | ShouldEmitIndexFiles, | ||
| bool | ShouldEmitImportsFiles, | ||
| StringRef | LinkerOutputFile, | ||
| StringRef | Distributor, | ||
| ArrayRef< StringRef > | DistributorArgs, | ||
| StringRef | RemoteCompiler, | ||
| ArrayRef< StringRef > | RemoteCompilerPrependArgs, | ||
| ArrayRef< StringRef > | RemoteCompilerArgs, | ||
| bool | SaveTemps ) |
This ThinBackend generates the index shards and then runs the individual backend jobs via an external process.
It takes the same parameters as the InProcessThinBackend; however, these parameters only control the behavior when generating the index files for the modules. Additionally: LinkerOutputFile is a string that should identify this LTO invocation in the context of a wider build. It's used for naming to aid the user in identifying activity related to a specific LTO invocation. Distributor specifies the path to a process to invoke to manage the backend job execution. DistributorArgs specifies a list of arguments to be applied to the distributor. RemoteCompiler specifies the path to a Clang executable to be invoked for the backend jobs. RemoteCompilerPrependArgs specifies a list of prepend arguments to be applied to the backend compilations. RemoteCompilerArgs specifies a list of arguments to be applied to the backend compilations. SaveTemps is a debugging tool that prevents temporary files created by this backend from being cleaned up.
Definition at line 2612 of file LTO.cpp.
◆ createWriteIndexesThinBackend()
This ThinBackend writes individual module indexes to files, instead of running the individual backend jobs.
This backend is for distributed builds where separate processes will invoke the real backends.
To find the path to write the index to, the backend checks if the path has a prefix of OldPrefix; if so, it replaces that prefix with NewPrefix. It then appends ".thinlto.bc" and writes the index to that path. If ShouldEmitImportsFiles is true it also writes a list of imported files to a similar path with ".imports" appended instead. LinkedObjectsFile is an output stream to write the list of object files for the final ThinLTO linking. Can be nullptr. If LinkedObjectsFile is not nullptr and NativeObjectPrefix is not empty then it replaces the prefix of the objects with NativeObjectPrefix instead of NewPrefix. OnWrite is callback which receives module identifier and notifies LTO user that index file for the module (and optionally imports file) was created.
Definition at line 1879 of file LTO.cpp.
◆ finalizeOptimizationRemarks()
◆ findThinLTOModule() [1/2]
◆ findThinLTOModule() [2/2]
◆ generateModulesOrdering()
◆ getThinLTODefaultCPU()
◆ getThinLTOOutputFile()
◆ initImportList()
◆ opt()
Runs middle-end LTO optimizations on Mod.
Definition at line 365 of file LTOBackend.cpp.
References llvm::dbgs(), EmbedBitcode, llvm::embedBitcodeInModule(), EmbedPostMergePreOptimized, isEmptyModule(), LLVM_DEBUG, llvm::Mod, llvm::lto::Config::OptLevel, llvm::lto::Config::PostOptModuleHook, and runNewPMPasses().
Referenced by backend(), and thinBackend().
◆ setupLLVMOptimizationRemarks()
◆ setupStatsFile()
◆ thinBackend()
| Error llvm::lto::thinBackend | ( | const Config & | C, |
|---|---|---|---|
| unsigned | Task, | ||
| AddStreamFn | AddStream, | ||
| Module & | M, | ||
| const ModuleSummaryIndex & | CombinedIndex, | ||
| const FunctionImporter::ImportMapTy & | ImportList, | ||
| const GVSummaryMapTy & | DefinedGlobals, | ||
| MapVector< StringRef, BitcodeModule > * | ModuleMap, | ||
| bool | CodeGenOnly, | ||
| AddStreamFn | IRAddStream = nullptr, | ||
| const std::vector< uint8_t > & | CmdArgs = std::vector<uint8_t>() ) |
Runs a ThinLTO backend.
If ModuleMap is not nullptr, all the module files to be imported have already been mapped to memory and the corresponding BitcodeModule objects are saved in the ModuleMap. If ModuleMap is nullptr, module files will be mapped to memory on demand and at any given time during importing, only one source module will be kept open at the most. If CodeGenOnly is true, the backend will skip optimization and only perform code generation. If IRAddStream is not nullptr, it will be called just before code generation to serialize the optimized IR.
Definition at line 608 of file LTOBackend.cpp.
References assert(), createTargetMachine(), llvm::dbgs(), llvm::PIELevel::Default, dropDeadSymbols(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(), finalizeOptimizationRemarks(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::find(), findThinLTOModule(), llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), I, llvm::FunctionImporter::importFunctions(), llvm::inconvertibleErrorCode(), initAndLookupTarget(), LLVM_DEBUG, llvm::make_error(), llvm::Mod, opt(), llvm::lto::Config::PostImportModuleHook, llvm::lto::Config::PostInternalizeModuleHook, llvm::lto::Config::PostPromoteModuleHook, llvm::lto::Config::PreOptModuleHook, llvm::lto::Config::RemarksFilename, llvm::lto::Config::RemarksFormat, llvm::lto::Config::RemarksHotnessThreshold, llvm::lto::Config::RemarksPasses, llvm::lto::Config::RemarksWithHotness, llvm::renameModuleForThinLTO(), llvm::cgdata::saveModuleForTwoRounds(), setupLLVMOptimizationRemarks(), llvm::Reloc::Static, llvm::Expected< T >::takeError(), ThinLTOAssumeMerged, llvm::thinLTOFinalizeInModule(), llvm::thinLTOInternalizeModule(), llvm::toString(), llvm::updatePublicTypeTestCalls(), and llvm::ModuleSummaryIndex::withWholeProgramVisibility().