LLVM
8.0.1
|
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 |
class | NativeObjectStream |
This class wraps an output stream for a native object. More... | |
struct | SymbolResolution |
The resolution for a symbol. More... | |
class | ThinBackendProc |
This class defines the interface to the ThinLTO backend. More... | |
Typedefs | |
typedef std::function< void(unsigned Task, std::unique_ptr< MemoryBuffer > MB)> | AddBufferFn |
This type defines the callback to add a pre-existing native object file (e.g. More... | |
typedef 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. More... | |
typedef std::function< AddStreamFn(unsigned Task, StringRef Key)> | NativeObjectCache |
This is the type of a native object cache. More... | |
typedef 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. More... | |
using | IndexWriteCallback = std::function< void(const std::string &)> |
This ThinBackend writes individual module indexes to files, instead of running the individual backend jobs. More... | |
Functions | |
Expected< NativeObjectCache > | localCache (StringRef CacheDirectoryPath, AddBufferFn AddBuffer) |
Create a local file system cache which uses the given cache directory and file callback. More... | |
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 . More... | |
Expected< std::unique_ptr< ToolOutputFile > > | setupOptimizationRemarks (LLVMContext &Context, StringRef LTORemarksFilename, bool LTOPassRemarksWithHotness, int Count=-1) |
Setup optimization remarks. More... | |
ThinBackend | createInProcessThinBackend (unsigned ParallelismLevel) |
This ThinBackend runs the individual backend jobs in-process. More... | |
ThinBackend | createWriteIndexesThinBackend (std::string OldPrefix, std::string NewPrefix, bool ShouldEmitImportsFiles, raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite) |
Error | backend (Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr< Module > M, ModuleSummaryIndex &CombinedIndex) |
Runs a regular LTO backend. More... | |
Error | thinBackend (Config &C, unsigned Task, AddStreamFn AddStream, Module &M, const ModuleSummaryIndex &CombinedIndex, const FunctionImporter::ImportMapTy &ImportList, const GVSummaryMapTy &DefinedGlobals, MapVector< StringRef, BitcodeModule > &ModuleMap) |
Runs a ThinLTO backend. More... | |
typedef std::function<void(unsigned Task, std::unique_ptr<MemoryBuffer> MB)> llvm::lto::AddBufferFn |
typedef std::function<std::unique_ptr<NativeObjectStream>unsigned Task)> llvm::lto::AddStreamFn |
using llvm::lto::IndexWriteCallback = typedef std::function<void(const std::string &)> |
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. OnWrite is callback which receives module identifier and notifies LTO user that index file for the module (and optionally imports file) was created.
typedef std::function<AddStreamFn(unsigned Task, StringRef Key)> llvm::lto::NativeObjectCache |
This is the type of a native object cache.
To request an item from the cache, pass a unique string as the Key. For hits, the cached file will be added to the link and this function will return AddStreamFn(). For misses, the cache will return a stream callback which must be called at most once to produce content for the stream. The native object stream produced by the stream callback will add the file to the link after the stream is written to.
Clients generally look like this:
if (AddStreamFn AddStream = Cache(Task, Key)) ProduceContent(AddStream);
typedef std::function<std::unique_ptr<ThinBackendProc> Config &C, ModuleSummaryIndex &CombinedIndex, StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries, AddStreamFn AddStream, NativeObjectCache Cache)> llvm::lto::ThinBackend |
Error llvm::lto::backend | ( | Config & | C, |
AddStreamFn | AddStream, | ||
unsigned | ParallelCodeGenParallelismLevel, | ||
std::unique_ptr< Module > | M, | ||
ModuleSummaryIndex & | CombinedIndex | ||
) |
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 410 of file LTOBackend.cpp.
References codegen(), llvm::lto::Config::CodeGenOnly, finalizeOptimizationRemarks(), opt, llvm::lto::Config::RemarksFilename, llvm::lto::Config::RemarksWithHotness, setupOptimizationRemarks(), llvm::splitCodeGen(), llvm::Expected< T >::takeError(), and llvm::SystemZISD::TM.
ThinBackend llvm::lto::createInProcessThinBackend | ( | unsigned | ParallelismLevel | ) |
This ThinBackend runs the individual backend jobs in-process.
Definition at line 1064 of file LTO.cpp.
Referenced by llvm::lto::InputFile::getName().
ThinBackend llvm::lto::createWriteIndexesThinBackend | ( | std::string | OldPrefix, |
std::string | NewPrefix, | ||
bool | ShouldEmitImportsFiles, | ||
raw_fd_ostream * | LinkedObjectsFile, | ||
IndexWriteCallback | OnWrite | ||
) |
Definition at line 1152 of file LTO.cpp.
References llvm::lto::Config::CombinedIndexHook, llvm::ComputeCrossModuleImport(), llvm::computeSyntheticCounts(), llvm::tgtok::Def, llvm::GlobalValue::dropLLVMManglingEscape(), DumpThinCGSCCs, E, llvm::GlobalValue::getGUID(), llvm::lto::Config::OptLevel, llvm::outs(), llvm::Error::success(), llvm::thinLTOInternalizeAndPromoteInIndex(), llvm::thinLTOResolvePrevailingInIndex(), and llvm::StringMap< ValueTy, AllocatorTy >::try_emplace().
std::string llvm::lto::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
.
Also, create the resulting directory if it does not yet exist.
Definition at line 1077 of file LTO.cpp.
References llvm::sys::fs::create_directories(), llvm::EmitImportsFiles(), llvm::StringRef::empty(), llvm::errorCodeToError(), llvm::errs(), llvm::sys::fs::F_None, llvm::gatherImportedSummariesForModule(), llvm::BitcodeModule::getModuleIdentifier(), llvm::sys::path::parent_path(), llvm::sys::path::replace_path_prefix(), llvm::SmallString< InternalLen >::str(), llvm::Error::success(), and llvm::WriteIndexToFile().
Expected< NativeObjectCache > llvm::lto::localCache | ( | StringRef | CacheDirectoryPath, |
AddBufferFn | AddBuffer | ||
) |
Create a local file system cache which uses the given cache directory and file callback.
This function also creates the cache directory if it does not already exist.
Definition at line 31 of file Caching.cpp.
References llvm::sys::path::append(), llvm::consumeError(), llvm::ECError::convertToErrorCode(), llvm::sys::fs::TempFile::create(), llvm::sys::fs::create_directories(), llvm::sys::fs::TempFile::discard(), E, llvm::errorCodeToError(), llvm::errs(), llvm::sys::fs::TempFile::FD, llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getMemBufferCopy(), llvm::MemoryBuffer::getOpenFile(), llvm::handleErrors(), llvm::sys::fs::TempFile::keep(), llvm::no_such_file_or_directory, llvm::sys::fs::OF_UpdateAtime, llvm::sys::fs::openFileForRead(), llvm::sys::fs::owner_read, llvm::sys::fs::owner_write, llvm::permission_denied, llvm::report_fatal_error(), llvm::SmallString< InternalLen >::str(), llvm::Error::success(), llvm::Expected< T >::takeError(), llvm::sys::fs::TempFile::TmpName, and llvm::toString().
Expected< std::unique_ptr< ToolOutputFile > > llvm::lto::setupOptimizationRemarks | ( | LLVMContext & | Context, |
StringRef | LTORemarksFilename, | ||
bool | LTOPassRemarksWithHotness, | ||
int | Count = -1 |
||
) |
Setup optimization remarks.
Definition at line 1267 of file LTO.cpp.
References llvm::StringRef::empty(), llvm::errorCodeToError(), llvm::sys::fs::F_None, llvm::LTORemarksFilename, llvm::LLVMContext::setDiagnosticsHotnessRequested(), llvm::LLVMContext::setDiagnosticsOutputFile(), and llvm::utostr().
Referenced by backend(), llvm::LTOCodeGenerator::optimize(), llvm::ThinLTOCodeGenerator::run(), and thinBackend().
Error llvm::lto::thinBackend | ( | Config & | C, |
unsigned | Task, | ||
AddStreamFn | AddStream, | ||
Module & | M, | ||
const ModuleSummaryIndex & | CombinedIndex, | ||
const FunctionImporter::ImportMapTy & | ImportList, | ||
const GVSummaryMapTy & | DefinedGlobals, | ||
MapVector< StringRef, BitcodeModule > & | ModuleMap | ||
) |
Runs a ThinLTO backend.
Definition at line 463 of file LTOBackend.cpp.
References assert(), codegen(), llvm::lto::Config::CodeGenOnly, dropDeadSymbols(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(), finalizeOptimizationRemarks(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::find(), llvm::Module::getContext(), I, llvm::LLVMContext::isODRUniquingDebugTypes(), llvm::lto::Config::PostInternalizeModuleHook, llvm::lto::Config::PostPromoteModuleHook, llvm::lto::Config::PreOptModuleHook, llvm::lto::Config::RemarksFilename, llvm::lto::Config::RemarksWithHotness, llvm::renameModuleForThinLTO(), setupOptimizationRemarks(), llvm::Expected< T >::takeError(), llvm::thinLTOInternalizeModule(), llvm::thinLTOResolvePrevailingInModule(), and llvm::SystemZISD::TM.