LLVM  4.0.0
Classes | Typedefs | Functions
llvm::lto Namespace Reference

Classes

struct  Config
 LTO configuration. More...
 
struct  LTOLLVMContext
 A derived class of LLVMContext that initializes itself according to a given Config object. More...
 
class  InputFile
 An input file. More...
 
class  NativeObjectStream
 This class wraps an output stream for a native object. More...
 
class  LTO
 This class implements a resolution-based interface to LLVM's LTO functionality. 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, StringRef Path)> 
AddFileFn
 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...
 

Functions

NativeObjectCache localCache (std::string CacheDirectoryPath, AddFileFn AddFile)
 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...
 
ThinBackend createInProcessThinBackend (unsigned ParallelismLevel)
 This ThinBackend runs the individual backend jobs in-process. More...
 
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 jobs. More...
 
Error backend (Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, std::unique_ptr< Module > M)
 Runs a regular LTO backend. More...
 
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. More...
 

Typedef Documentation

This type defines the callback to add a pre-existing native object file (e.g.

in a cache).

File callbacks must be thread safe.

Definition at line 28 of file Caching.h.

This type defines the callback to add a native object that is generated on the fly.

Stream callbacks must be thread safe.

Definition at line 253 of file LTO.h.

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);

Definition at line 268 of file LTO.h.

typedef std::function<std::unique_ptr<ThinBackendProc> Config &C, ModuleSummaryIndex &CombinedIndex, StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries, AddStreamFn AddStream, NativeObjectCache Cache)> llvm::lto::ThinBackend

A ThinBackend defines what happens after the thin-link phase during ThinLTO.

The details of this type definition aren't important; clients can only create a ThinBackend using one of the create*ThinBackend() functions below.

Definition at line 277 of file LTO.h.

Function Documentation

Error llvm::lto::backend ( Config C,
AddStreamFn  AddStream,
unsigned  ParallelCodeGenParallelismLevel,
std::unique_ptr< Module M 
)
ThinBackend llvm::lto::createInProcessThinBackend ( unsigned  ParallelismLevel)

This ThinBackend runs the individual backend jobs in-process.

Definition at line 732 of file LTO.cpp.

ThinBackend llvm::lto::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 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.

Definition at line 822 of file LTO.cpp.

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 745 of file LTO.cpp.

References llvm::sys::fs::create_directories(), llvm::StringRef::empty(), llvm::errs(), llvm::sys::path::parent_path(), llvm::sys::path::replace_path_prefix(), and llvm::SmallString< InternalLen >::str().

NativeObjectCache llvm::lto::localCache ( std::string  CacheDirectoryPath,
AddFileFn  AddFile 
)

Create a local file system cache which uses the given cache directory and file callback.

Definition at line 49 of file Caching.cpp.

References llvm::sys::path::append(), commitEntry(), llvm::sys::fs::createTemporaryFile(), llvm::errs(), llvm::sys::fs::exists(), llvm::report_fatal_error(), and llvm::SmallString< InternalLen >::str().

Error llvm::lto::thinBackend ( Config C,
unsigned  Task,
AddStreamFn  AddStream,
Module M,
ModuleSummaryIndex CombinedIndex,
const FunctionImporter::ImportMapTy ImportList,
const GVSummaryMapTy DefinedGlobals,
MapVector< StringRef, BitcodeModule > &  ModuleMap 
)