LLVM 23.0.0git
llvm::lto::DTLTO Class Reference

Prepares inputs for Distributed ThinLTO so that backend compilations can use individual bitcode paths and consistent module IDs. More...

#include "llvm/DTLTO/DTLTO.h"

Inheritance diagram for llvm::lto::DTLTO:
[legend]

Classes

struct  DistributionDriverParams
struct  Job

Public Member Functions

LLVM_ABI 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)
LLVM_ABI Expected< std::shared_ptr< InputFile > > addInput (std::unique_ptr< InputFile > InputPtr) override
 Add an input file and prepare it for distribution.
virtual LLVM_ABI Error run (AddStreamFn AddStream, FileCache Cache={}) override
 Runs the DTLTO pipeline.
ConfiggetConfig ()
const ConfiggetConfig () const
Public Member Functions inherited from llvm::lto::LTO
LLVM_ABI LTO (Config Conf, ThinBackend Backend={}, unsigned ParallelCodeGenParallelismLevel=1, LTOKind LTOMode=LTOK_Default)
 Create an LTO object.
virtual LLVM_ABI ~LTO ()
LLVM_ABI Error add (std::unique_ptr< InputFile > Obj, ArrayRef< SymbolResolution > Res)
 Add an input file to the LTO link, using the provided symbol resolutions.
LLVM_ABI void setBitcodeLibFuncs (ArrayRef< StringRef > BitcodeLibFuncs)
 Set the list of functions implemented in bitcode that were not extracted from an archive.
LLVM_ABI unsigned getMaxTasks () const
 Returns an upper bound on the number of tasks that the client may expect.
void emitRemark (OptimizationRemark &Remark)
 Helper to emit an optimization remark during the LTO link when outside of the standard optimization pass pipeline.
virtual Expected< std::shared_ptr< lto::InputFile > > addInput (std::unique_ptr< lto::InputFile > InputPtr)

Static Public Member Functions

static lto::ThinBackend writeIndexesBackendInstance ()
Static Public Member Functions inherited from llvm::lto::LTO
static LLVM_ABI 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.
static LLVM_ABI SmallVector< StringRefgetLibFuncSymbols (const Triple &TT, llvm::StringSaver &Saver)
 Static method that returns a list of library function symbols that can be generated by LTO but might not be visible from bitcode symbol table.

Additional Inherited Members

Public Types inherited from llvm::lto::LTO
enum  LTOKind { LTOK_Default , LTOK_UnifiedRegular , LTOK_UnifiedThin }
 Unified LTO modes. More...
Protected Types inherited from llvm::lto::LTO
using ModuleMapType = MapVector<StringRef, BitcodeModule>
Protected Attributes inherited from llvm::lto::LTO
Config Conf
struct llvm::lto::LTO::RegularLTOState RegularLTO
struct llvm::lto::LTO::ThinLTOState ThinLTO
LTOKind LTOMode

Detailed Description

Prepares inputs for Distributed ThinLTO so that backend compilations can use individual bitcode paths and consistent module IDs.

Each input must exist as an individual bitcode file on disk and be loadable via its ModuleID. Archive members and FatLTO objects do not satisfy that by default; this class writes bitcode out when needed and updates ModuleID. On Windows, module IDs are normalized to remove short 8.3 path components that are machine-local and break distribution; other normalization is left to DTLTO distributors.

Input files are kept until the pipeline has determined per-module ThinLTO participation. addInput() performs: (1) register the input; (2) on Windows, normalize module ID for standalone bitcode; (3) for thin archive members, set module ID to the on-disk member path; (4) for other archives and FatLTO, set module ID to a unique path and serialize content in serializeLTOInputs().

Definition at line 46 of file DTLTO.h.

Constructor & Destructor Documentation

◆ DTLTO()

LLVM_ABI llvm::lto::DTLTO::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 )
inline

Member Function Documentation

◆ addInput()

Expected< std::shared_ptr< lto::InputFile > > lto::DTLTO::addInput ( std::unique_ptr< InputFile > InputPtr)
override

Add an input file and prepare it for distribution.

This function performs the following tasks:

  1. Add the input file to the LTO object's list of input files.
  2. For individual bitcode file inputs on Windows only, overwrite the module ID with a normalized path to remove short 8.3 form components.
  3. For thin archive members, overwrite the module ID with the path (normalized on Windows) to the member file on disk.
  4. For archive members and FatLTO objects, overwrite the module ID with a unique path (normalized on Windows) naming a file that will contain the member content. The file is created and populated later (see serializeInputs()).

Definition at line 134 of file DTLTOInputFiles.cpp.

References llvm::sys::path::append(), llvm::StringRef::empty(), llvm::sys::path::filename(), llvm::sys::Process::getProcessId(), N, llvm::sys::path::parent_path(), llvm::BitcodeModule::setModuleIdentifier(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::utohexstr().

◆ getConfig() [1/2]

Config & llvm::lto::DTLTO::getConfig ( )
inline

Definition at line 119 of file DTLTO.h.

References llvm::lto::LTO::Conf.

◆ getConfig() [2/2]

const Config & llvm::lto::DTLTO::getConfig ( ) const
inline

Definition at line 120 of file DTLTO.h.

References llvm::lto::LTO::Conf.

◆ run()

LLVM_ABI Error lto::DTLTO::run ( AddStreamFn AddStream,
FileCache Cache = {} )
overridevirtual

Runs the DTLTO 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.

Reimplemented from llvm::lto::LTO.

Definition at line 77 of file DTLTO.cpp.

References cleanup(), llvm::lto::LTO::Conf, llvm::sys::Process::getProcessId(), llvm::itostr(), LLVM_ABI, llvm::lto::LTO::RegularLTO, and llvm::Error::success().

◆ writeIndexesBackendInstance()

lto::ThinBackend llvm::lto::DTLTO::writeIndexesBackendInstance ( )
inlinestatic

Definition at line 71 of file DTLTO.h.

References llvm::lto::createWriteIndexesThinBackend(), and llvm::hardware_concurrency().

Referenced by DTLTO().


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