16#ifndef LLVM_DTLTO_DTLTO_H
17#define LLVM_DTLTO_DTLTO_H
59 ParallelCodeGenParallelismLevel,
LTOMode),
60 AddBuffer(AddBufferArg), SaveTemps(SaveTempsArg),
61 ShouldEmitIndexFiles(EmitIndexFiles),
63 DistributorParams{Distributor, DistributorArgs,
64 RemoteCompiler, RemoteCompilerPrependArgs,
65 RemoteCompilerArgs, LinkerOutputFile} {
66 assert(!LinkerOutputFile.
empty() &&
"expected a valid linker output file");
73 "",
true,
nullptr,
nullptr);
89 addInput(std::unique_ptr<InputFile> InputPtr)
override;
133 std::atomic<size_t> CachedJobs{0};
135 SString LinkerOutputDir;
137 bool SaveTemps =
false;
140 static Error save(StringRef Buffer, StringRef Path);
169 unsigned ThinLTOTaskOffset;
173 bool ShouldEmitIndexFiles =
false;
175 bool ShouldEmitImportFiles =
false;
237 Error prepareDtltoJobs();
247 Error performCodegen();
257 Error addObjectFilesToLink();
269 std::vector<std::shared_ptr<lto::InputFile>> InputFiles;
275 std::vector<SmallString<0>> SummaryIndexFiles;
277 std::vector<std::vector<std::string>> ImportsFilesList;
279 std::vector<std::string> CacheKeysList;
300 Error performThinLink();
311 void buildCommonRemoteCompilerOptions();
356 std::vector<std::string> CleanupList;
360 CleanupList.push_back(
Filename.str());
366constexpr StringRef BCError =
"DTLTO backend compilation: ";
374 std::function<
void(
StringRef)> AddToClenupArg)
375 : Params{ParamsArg}, SaveTemps{SaveTempsArg},
376 AddToCleanup{AddToClenupArg}, Jobs{JobsArg} {};
381 bool SaveTemps =
false;
382 std::function<void(
StringRef)> AddToCleanup;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static constexpr StringLiteral Filename
This file defines the SmallString class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Triple - Helper class for working with autoconf configuration names.
const Config & getConfig() const
virtual LLVM_ABI Error run(AddStreamFn AddStream, FileCache Cache={}) override
Runs the DTLTO pipeline.
LLVM_ABI Expected< std::shared_ptr< InputFile > > addInput(std::unique_ptr< InputFile > InputPtr) override
Add an input file and prepare it for distribution.
LLVM_ABI DTLTO(Config Conf, unsigned ParallelCodeGenParallelismLevel, LTOKind LTOMode, IndexWriteCallback OnWrite, bool EmitIndexFiles, bool EmitImportsFiles, StringRef LinkerOutputFile, StringRef Distributor, ArrayRef< StringRef > DistributorArgs, StringRef RemoteCompiler, ArrayRef< StringRef > RemoteCompilerPrependArgs, ArrayRef< StringRef > RemoteCompilerArgs, AddBufferFn AddBufferArg, bool SaveTempsArg)
static lto::ThinBackend writeIndexesBackendInstance()
LLVM_ABI DistributionDriver(DTLTO::DistributionDriverParams &ParamsArg, ArrayRef< DTLTO::Job > JobsArg, bool SaveTempsArg, std::function< void(StringRef)> AddToClenupArg)
Error operator()()
Invokes the distributor to compile bitcode modules remotely.
LLVM_ABI LTO(Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
Create an LTO object.
LTOKind
Unified LTO modes.
@ LTOK_UnifiedThin
ThinLTO, with Unified LTO enabled.
std::function< void(const std::string &)> IndexWriteCallback
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...
LLVM_ABI bool RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg=nullptr)
This function registers signal handlers to ensure that if a signal gets delivered that the named file...
This is an optimization pass for GlobalISel generic memory operations.
ThreadPoolStrategy hardware_concurrency(unsigned ThreadCount=0)
Returns a default thread strategy where all available hardware resources are to be used,...
std::function< void(unsigned Task, const Twine &ModuleName, std::unique_ptr< MemoryBuffer > MB)> AddBufferFn
This type defines the callback to add a pre-existing file (e.g.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
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.
LLVM_ABI Error EmitImportsFiles(StringRef ModulePath, StringRef OutputFilename, const ModuleToSummariesForIndexTy &ModuleToSummariesForIndex)
Emit into OutputFilename the files module ModulePath will import from.
Implement std::hash so that hash_code can be used in STL containers.
This type represents a file cache system that manages caching of files.
ArrayRef< StringRef > DistributorArgs
LLVM_ABI DistributionDriverParams()=default
ArrayRef< StringRef > RemoteCompilerArgs
SmallVector< StringRef, 0 > CodegenOptions
DistributionDriverParams(StringRef DistributorArg, ArrayRef< StringRef > DistributorArgsArg, StringRef RemoteCompilerArg, ArrayRef< StringRef > RemoteCompilerPrependArgsArg, ArrayRef< StringRef > RemoteCompilerArgsArg, StringRef LinkerOutputFileArg)
DenseSet< StringRef > CommonInputs
ArrayRef< StringRef > RemoteCompilerPrependArgs
StringRef SummaryIndexPath
AddStreamFn CacheAddStream
StringRef NativeObjectPath
ArrayRef< std::string > ImportsFilesList
This type defines the behavior following the thin-link phase during ThinLTO.