LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::lto::LTO Class Reference

This class implements a resolution-based interface to LLVM's LTO functionality. More...

#include "llvm/LTO/LTO.h"

Public Types

enum  LTOKind { LTOK_Default , LTOK_UnifiedRegular , LTOK_UnifiedThin }
 Unified LTO modes. More...
 

Public Member Functions

 LTO (Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
 Create an LTO object.
 
 ~LTO ()
 
Error add (std::unique_ptr< InputFile > Obj, ArrayRef< SymbolResolution > Res)
 Add an input file to the LTO link, using the provided symbol resolutions.
 
unsigned getMaxTasks () const
 Returns an upper bound on the number of tasks that the client may expect.
 
Error run (AddStreamFn AddStream, FileCache Cache={})
 Runs the LTO pipeline.
 

Static Public Member Functions

static SmallVector< const char * > getRuntimeLibcallSymbols (const Triple &TT)
 Static method that returns a list of libcall symbols that can be generated by LTO but might not be visible from bitcode symbol table.
 

Detailed 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:

Definition at line 336 of file LTO.h.

Member Enumeration Documentation

◆ LTOKind

Unified LTO modes.

Enumerator
LTOK_Default 

Any LTO mode without Unified LTO. The default mode.

LTOK_UnifiedRegular 

Regular LTO, with Unified LTO enabled.

LTOK_UnifiedThin 

ThinLTO, with Unified LTO enabled.

Definition at line 341 of file LTO.h.

Constructor & Destructor Documentation

◆ LTO()

LTO::LTO ( Config  Conf,
ThinBackend  Backend = {},
unsigned  ParallelCodeGenParallelismLevel = 1,
LTOKind  LTOMode = LTOK_Default 
)

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.

Definition at line 607 of file LTO.cpp.

References llvm::lto::Config::KeepSymbolNameCopies, and llvm::LTOKeepSymbolCopies.

◆ ~LTO()

LTO::~LTO ( )
default

Member Function Documentation

◆ add()

Error LTO::add ( std::unique_ptr< InputFile Obj,
ArrayRef< SymbolResolution Res 
)

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().

Definition at line 728 of file LTO.cpp.

References assert(), llvm::ArrayRef< T >::begin(), llvm::lto::Config::ELF, llvm::ArrayRef< T >::end(), I, llvm::Triple::isOSBinFormatELF(), llvm::lto::Config::ResolutionFile, llvm::Error::success(), llvm::lto::Config::VisibilityScheme, and writeToResolutionFile().

◆ getMaxTasks()

unsigned LTO::getMaxTasks ( ) const

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.

Definition at line 1110 of file LTO.cpp.

◆ getRuntimeLibcallSymbols()

SmallVector< const char * > LTO::getRuntimeLibcallSymbols ( const Triple TT)
static

Static method that returns a list of libcall symbols that can be generated by LTO but might not be visible from bitcode symbol table.

Definition at line 1382 of file LTO.cpp.

References llvm::copy_if(), llvm::RTLIB::RuntimeLibcallsInfo::getLibcallNames(), and Name.

◆ run()

Error LTO::run ( AddStreamFn  AddStream,
FileCache  Cache = {} 
)

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.

Definition at line 1161 of file LTO.cpp.

References llvm::computeDeadSymbolsWithConstProp(), llvm::GlobalValue::dropLLVMManglingEscape(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::lto::SymbolResolution::ExportDynamic, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), G, llvm::GlobalValue::getGUID(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::No, llvm::lto::Config::OptLevel, llvm::lto::SymbolResolution::Prevailing, llvm::PrintStatisticsJSON(), llvm::lto::setupStatsFile(), llvm::lto::Config::StatsFile, llvm::SupportsHotColdNew, llvm::Unknown, and llvm::Yes.


The documentation for this class was generated from the following files: