class LTO
Declaration
class LTO { /* full declaration omitted */ };
Description
This class implements a resolution-based interface to LLVM's LTO functionality. It supports regular LTO, parallel LTO code generation and ThinLTO. You can use it from a linker in the following way: - Set hooks and code generation options (see lto::Config struct defined in Config.h), and use the lto::Config object to create an lto::LTO object. - Create lto::InputFile objects using lto::InputFile::create(), then use the symbols() function to enumerate its symbols and compute a resolution for each symbol (see SymbolResolution below). - After the linker has visited each input file (and each regular object file) and computed a resolution for each symbol, take each lto::InputFile and pass it and an array of symbol resolutions to the add() function. - Call the getMaxTasks() function to get an upper bound on the number of native object files that LTO may add to the link. - Call the run() function. This function will use the supplied AddStream and Cache functions to add up to getMaxTasks() native object files to the link.
Declared at: llvm/include/llvm/LTO/LTO.h:247
Member Variables
- private llvm::lto::Config Conf
- private struct RegularLTOState RegularLTO
- private struct ThinLTOState ThinLTO
- private StringMap<llvm::lto::LTO::GlobalResolution> GlobalResolutions
- private bool CalledGetMaxTasks = false
- private Optional<bool> EnableSplitLTOUnit
- private DenseSet<GlobalValue::GUID> DynamicExportSymbols
- private std::unique_ptr<ToolOutputFile> DiagnosticOutputFile
Method Overview
- public LTO(llvm::lto::Config Conf, llvm::lto::ThinBackend Backend = nullptr, unsigned int ParallelCodeGenParallelismLevel = 1)
- public llvm::Error add(std::unique_ptr<InputFile> Obj, ArrayRef<llvm::lto::SymbolResolution> Res)
- private llvm::Error addModule(llvm::lto::InputFile & Input, unsigned int ModI, const llvm::lto::SymbolResolution *& ResI, const llvm::lto::SymbolResolution * ResE)
- private void addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms, ArrayRef<llvm::lto::SymbolResolution> Res, unsigned int Partition, bool InSummary)
- private Expected<RegularLTOState::AddedModule> addRegularLTO(llvm::BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms, const llvm::lto::SymbolResolution *& ResI, const llvm::lto::SymbolResolution * ResE)
- private llvm::Error addThinLTO(llvm::BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms, const llvm::lto::SymbolResolution *& ResI, const llvm::lto::SymbolResolution * ResE)
- private llvm::Error checkPartiallySplit()
- public unsigned int getMaxTasks() const
- public static ArrayRef<const char *> getRuntimeLibcallSymbols()
- private llvm::Error linkRegularLTO(RegularLTOState::AddedModule Mod, bool LivenessFromIndex)
- public llvm::Error run(llvm::AddStreamFn AddStream, llvm::FileCache Cache = nullptr)
- private llvm::Error runRegularLTO(llvm::AddStreamFn AddStream)
- private llvm::Error runThinLTO(llvm::AddStreamFn AddStream, llvm::FileCache Cache, const DenseSet<GlobalValue::GUID> & GUIDPreservedSymbols)
- public ~LTO()
Methods
¶LTO(llvm::lto::Config Conf,
llvm::lto::ThinBackend Backend = nullptr,
unsigned int ParallelCodeGenParallelismLevel =
1)
LTO(llvm::lto::Config Conf,
llvm::lto::ThinBackend Backend = nullptr,
unsigned int ParallelCodeGenParallelismLevel =
1)
Description
Create an LTO object. A default constructed LTO object has a reasonable production configuration, but you can customize it by passing arguments to this constructor. FIXME: We do currently require the DiagHandler field to be set in Conf. Until that is fixed, a Config argument is required.
Declared at: llvm/include/llvm/LTO/LTO.h:256
Parameters
- llvm::lto::Config Conf
- llvm::lto::ThinBackend Backend = nullptr
- unsigned int ParallelCodeGenParallelismLevel = 1
¶llvm::Error add(
std::unique_ptr<InputFile> Obj,
ArrayRef<llvm::lto::SymbolResolution> Res)
llvm::Error add(
std::unique_ptr<InputFile> Obj,
ArrayRef<llvm::lto::SymbolResolution> Res)
Description
Add an input file to the LTO link, using the provided symbol resolutions. The symbol resolutions must appear in the enumeration order given by InputFile::symbols().
Declared at: llvm/include/llvm/LTO/LTO.h:263
Parameters
- std::unique_ptr<InputFile> Obj
- ArrayRef<llvm::lto::SymbolResolution> Res
¶llvm::Error addModule(
llvm::lto::InputFile& Input,
unsigned int ModI,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
llvm::Error addModule(
llvm::lto::InputFile& Input,
unsigned int ModI,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
Declared at: llvm/include/llvm/LTO/LTO.h:397
Parameters
- llvm::lto::InputFile& Input
- unsigned int ModI
- const llvm::lto::SymbolResolution*& ResI
- const llvm::lto::SymbolResolution* ResE
¶void addModuleToGlobalRes(
ArrayRef<InputFile::Symbol> Syms,
ArrayRef<llvm::lto::SymbolResolution> Res,
unsigned int Partition,
bool InSummary)
void addModuleToGlobalRes(
ArrayRef<InputFile::Symbol> Syms,
ArrayRef<llvm::lto::SymbolResolution> Res,
unsigned int Partition,
bool InSummary)
Declared at: llvm/include/llvm/LTO/LTO.h:389
Parameters
- ArrayRef<InputFile::Symbol> Syms
- ArrayRef<llvm::lto::SymbolResolution> Res
- unsigned int Partition
- bool InSummary
¶Expected<RegularLTOState::AddedModule>
addRegularLTO(
llvm::BitcodeModule BM,
ArrayRef<InputFile::Symbol> Syms,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
Expected<RegularLTOState::AddedModule>
addRegularLTO(
llvm::BitcodeModule BM,
ArrayRef<InputFile::Symbol> Syms,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
Declared at: llvm/include/llvm/LTO/LTO.h:401
Parameters
- llvm::BitcodeModule BM
- ArrayRef<InputFile::Symbol> Syms
- const llvm::lto::SymbolResolution*& ResI
- const llvm::lto::SymbolResolution* ResE
¶llvm::Error addThinLTO(
llvm::BitcodeModule BM,
ArrayRef<InputFile::Symbol> Syms,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
llvm::Error addThinLTO(
llvm::BitcodeModule BM,
ArrayRef<InputFile::Symbol> Syms,
const llvm::lto::SymbolResolution*& ResI,
const llvm::lto::SymbolResolution* ResE)
Declared at: llvm/include/llvm/LTO/LTO.h:406
Parameters
- llvm::BitcodeModule BM
- ArrayRef<InputFile::Symbol> Syms
- const llvm::lto::SymbolResolution*& ResI
- const llvm::lto::SymbolResolution* ResE
¶llvm::Error checkPartiallySplit()
llvm::Error checkPartiallySplit()
Declared at: llvm/include/llvm/LTO/LTO.h:413
¶unsigned int getMaxTasks() const
unsigned int getMaxTasks() const
Description
Returns an upper bound on the number of tasks that the client may expect. This may only be called after all IR object files have been added. For a full description of tasks see LTOBackend.h.
Declared at: llvm/include/llvm/LTO/LTO.h:268
¶static ArrayRef<const char*>
getRuntimeLibcallSymbols()
static ArrayRef<const char*>
getRuntimeLibcallSymbols()
Description
Static method that returns a list of libcall symbols that can be generated by LTO but might not be visible from bitcode symbol table.
Declared at: llvm/include/llvm/LTO/LTO.h:282
¶llvm::Error linkRegularLTO(
RegularLTOState::AddedModule Mod,
bool LivenessFromIndex)
llvm::Error linkRegularLTO(
RegularLTOState::AddedModule Mod,
bool LivenessFromIndex)
Declared at: llvm/include/llvm/LTO/LTO.h:403
Parameters
- RegularLTOState::AddedModule Mod
- bool LivenessFromIndex
¶llvm::Error run(llvm::AddStreamFn AddStream,
llvm::FileCache Cache = nullptr)
llvm::Error run(llvm::AddStreamFn AddStream,
llvm::FileCache Cache = nullptr)
Description
Runs the LTO pipeline. This function calls the supplied AddStream function to add native object files to the link. The Cache parameter is optional. If supplied, it will be used to cache native object files and add them to the link. The client will receive at most one callback (via either AddStream or Cache) for each task identifier.
Declared at: llvm/include/llvm/LTO/LTO.h:278
Parameters
- llvm::AddStreamFn AddStream
- llvm::FileCache Cache = nullptr
¶llvm::Error runRegularLTO(
llvm::AddStreamFn AddStream)
llvm::Error runRegularLTO(
llvm::AddStreamFn AddStream)
Declared at: llvm/include/llvm/LTO/LTO.h:409
Parameters
- llvm::AddStreamFn AddStream
¶llvm::Error runThinLTO(
llvm::AddStreamFn AddStream,
llvm::FileCache Cache,
const DenseSet<GlobalValue::GUID>&
GUIDPreservedSymbols)
llvm::Error runThinLTO(
llvm::AddStreamFn AddStream,
llvm::FileCache Cache,
const DenseSet<GlobalValue::GUID>&
GUIDPreservedSymbols)
Declared at: llvm/include/llvm/LTO/LTO.h:410
Parameters
- llvm::AddStreamFn AddStream
- llvm::FileCache Cache
- const DenseSet<GlobalValue::GUID>& GUIDPreservedSymbols
¶~LTO()
~LTO()
Declared at: llvm/include/llvm/LTO/LTO.h:258