16#ifndef LLVM_DTLTO_DTLTO_H
17#define LLVM_DTLTO_DTLTO_H
58 ParallelCodeGenParallelismLevel,
LTOMode),
59 AddBuffer(AddBufferArg), SaveTemps(SaveTempsArg),
60 ShouldEmitIndexFiles(EmitIndexFiles),
62 DistributorParams{Distributor, DistributorArgs,
63 RemoteCompiler, RemoteCompilerPrependArgs,
64 RemoteCompilerArgs, LinkerOutputFile} {
65 assert(!LinkerOutputFile.
empty() &&
"expected a valid linker output file");
72 "",
true,
nullptr,
nullptr);
88 addInput(std::unique_ptr<InputFile> InputPtr)
override;
110 Error serializeLTOInputs();
131 std::atomic<size_t> CachedJobs{0};
133 SString LinkerOutputDir;
135 bool SaveTemps =
false;
138 static Error save(StringRef Buffer, StringRef Path);
167 unsigned ThinLTOTaskOffset;
171 bool ShouldEmitIndexFiles =
false;
173 bool ShouldEmitImportFiles =
false;
235 Error prepareDtltoJobs();
245 Error performCodegen();
255 Error addObjectFilesToLink();
267 std::vector<std::shared_ptr<lto::InputFile>> InputFiles;
273 std::vector<SmallString<0>> SummaryIndexFiles;
275 std::vector<std::vector<std::string>> ImportsFilesList;
277 std::vector<std::string> CacheKeysList;
298 Error performThinLink();
309 void buildCommonRemoteCompilerOptions();
354 std::vector<std::string> CleanupList;
358 CleanupList.push_back(
Filename.str());
364constexpr StringRef BCError =
"DTLTO backend compilation: ";
371 std::function<
void(
StringRef)> AddToClenupArg)
372 : Params{ParamsArg}, SaveTemps{SaveTempsArg},
373 AddToCleanup{AddToClenupArg}, Jobs{JobsArg} {};
378 bool SaveTemps =
false;
379 std::function<void(
StringRef)> AddToCleanup;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
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
static lto::ThinBackend writeIndexesBackendInstance()
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)
DistributionDriver(DTLTO::DistributionDriverParams &ParamsArg, ArrayRef< DTLTO::Job > JobsArg, bool SaveTempsArg, std::function< void(StringRef)> AddToClenupArg)
LLVM_ABI Error operator()()
Invokes the distributor to compile bitcode modules remotely.
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
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.