LLVM 22.0.0git
llvm::ThinLTOCodeGenerator Class Reference

This class define an interface similar to the LTOCodeGenerator, but adapted for ThinLTO processing. More...

#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"

Classes

struct  CachingOptions

Public Member Functions

LLVM_ABI void addModule (StringRef Identifier, StringRef Data)
 Add given module to the code generator.
LLVM_ABI void preserveSymbol (StringRef Name)
 Adds to a list of all global symbols that must exist in the final generated code.
LLVM_ABI void crossReferenceSymbol (StringRef Name)
 Adds to a list of all global symbols that are cross-referenced between ThinLTO files.
LLVM_ABI void run ()
 Process all the modules that were added to the code generator in parallel.
std::vector< std::unique_ptr< MemoryBuffer > > & getProducedBinaries ()
 Return the "in memory" binaries produced by the code generator.
std::vector< std::string > & getProducedBinaryFiles ()
 Return the "on-disk" binaries produced by the code generator.
void setCacheDir (std::string Path)
 Provide a path to a directory where to store the cached files for incremental build.
void setCachePruningInterval (int Interval)
 Cache policy: interval (seconds) between two prunes of the cache.
void setCacheEntryExpiration (unsigned Expiration)
 Cache policy: expiration (in seconds) for an entry.
void setMaxCacheSizeRelativeToAvailableSpace (unsigned Percentage)
 Sets the maximum cache size that can be persistent across build, in terms of percentage of the available space on the disk.
void setCacheMaxSizeBytes (uint64_t MaxSizeBytes)
 Cache policy: the maximum size for the cache directory in bytes.
void setCacheMaxSizeFiles (unsigned MaxSizeFiles)
 Cache policy: the maximum number of files in the cache directory.
void setSaveTempsDir (std::string Path)
 Set the path to a directory where to save temporaries at various stages of the processing.
void setGeneratedObjectsDirectory (std::string Path)
 Set the path to a directory where to save generated object files.
void setCpu (std::string Cpu)
 CPU to use to initialize the TargetMachine.
void setAttr (std::string MAttr)
 Subtarget attributes.
void setTargetOptions (TargetOptions Options)
 TargetMachine options.
void setFreestanding (bool Enabled)
 Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target.
void setCodePICModel (std::optional< Reloc::Model > Model)
 CodeModel.
void setCodeGenOptLevel (CodeGenOptLevel CGOptLevel)
 CodeGen optimization level.
void setOptLevel (unsigned NewOptLevel)
 IR optimization level: from 0 to 3.
void setDebugPassManager (unsigned Enabled)
 Enable or disable debug output for the new pass manager.
void disableCodeGen (bool Disable)
 Disable CodeGen, only run the stages till codegen and stop.
void setCodeGenOnly (bool CGOnly)
 Perform CodeGen only: disable all other stages.
LLVM_ABI std::unique_ptr< ModuleSummaryIndexlinkCombinedIndex ()
 Produce the combined summary index from all the bitcode files: "thin-link".
LLVM_ABI void promote (Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Perform promotion and renaming of exported internal functions, and additionally resolve weak and linkonce symbols.
LLVM_ABI void emitImports (Module &Module, StringRef OutputName, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Compute and emit the imported files for module at ModulePath.
LLVM_ABI void crossModuleImport (Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Perform cross-module importing for the module identified by ModuleIdentifier.
LLVM_ABI void gatherImportedSummariesForModule (Module &Module, ModuleSummaryIndex &Index, ModuleToSummariesForIndexTy &ModuleToSummariesForIndex, GVSummaryPtrSet &DecSummaries, const lto::InputFile &File)
 Compute the list of summaries and the subset of declaration summaries needed for importing into module.
LLVM_ABI void internalize (Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Perform internalization.
LLVM_ABI void optimize (Module &Module)
 Perform post-importing ThinLTO optimizations.
LLVM_ABI std::string writeGeneratedObject (int count, StringRef CacheEntryPath, const MemoryBuffer &OutputBuffer)
 Write temporary object file to SavedObjectDirectoryPath, write symlink to Cache directory if needed.

Detailed Description

This class define an interface similar to the LTOCodeGenerator, but adapted for ThinLTO processing.

The ThinLTOCodeGenerator is not intended to be reuse for multiple compilation: the model is that the client adds modules to the generator and ask to perform the ThinLTO optimizations / codegen, and finally destroys the codegenerator.

Definition at line 60 of file ThinLTOCodeGenerator.h.

Member Function Documentation

◆ addModule()

void ThinLTOCodeGenerator::addModule ( StringRef Identifier,
StringRef Data )

Add given module to the code generator.

Definition at line 541 of file ThinLTOCodeGenerator.cpp.

References llvm::lto::InputFile::create(), llvm::Data, initTMBuilder(), llvm::report_fatal_error(), and llvm::toString().

◆ crossReferenceSymbol()

void ThinLTOCodeGenerator::crossReferenceSymbol ( StringRef Name)

Adds to a list of all global symbols that are cross-referenced between ThinLTO files.

If the ThinLTO CodeGenerator can ensure that every references from a ThinLTO module to this symbol is optimized away, then the symbol can be discarded.

Definition at line 568 of file ThinLTOCodeGenerator.cpp.

◆ getProducedBinaries()

std::vector< std::unique_ptr< MemoryBuffer > > & llvm::ThinLTOCodeGenerator::getProducedBinaries ( )
inline

Return the "in memory" binaries produced by the code generator.

This is filled after run() unless setGeneratedObjectsDirectory() has been called, in which case results are available through getProducedBinaryFiles().

Definition at line 95 of file ThinLTOCodeGenerator.h.

◆ getProducedBinaryFiles()

std::vector< std::string > & llvm::ThinLTOCodeGenerator::getProducedBinaryFiles ( )
inline

Return the "on-disk" binaries produced by the code generator.

This is filled after run() when setGeneratedObjectsDirectory() has been called, in which case results are available through getProducedBinaries().

Definition at line 104 of file ThinLTOCodeGenerator.h.

◆ preserveSymbol()

void ThinLTOCodeGenerator::preserveSymbol ( StringRef Name)

Adds to a list of all global symbols that must exist in the final generated code.

If a symbol is not listed there, it will be optimized away if it is inlined into every usage.

Definition at line 564 of file ThinLTOCodeGenerator.cpp.

◆ run()

void ThinLTOCodeGenerator::run ( )

Process all the modules that were added to the code generator in parallel.

Client can access the resulting object files using getProducedBinaries(), unless setGeneratedObjectsDirectory() has been called, in which case results are available through getProducedBinaryFiles().

Definition at line 956 of file ThinLTOCodeGenerator.cpp.

References addUsedSymbolToPreservedGUID(), llvm::AreStatisticsEnabled(), assert(), llvm::ThreadPoolInterface::async(), codegenModule(), llvm::ComputeCrossModuleImport(), computeDeadSymbolsInIndex(), computeGUIDPreservedSymbols(), computePrevailingCopies(), llvm::count(), llvm::sys::fs::create_directories(), llvm::dbgs(), llvm::errs(), generateModuleMap(), llvm::lto::generateModulesOrdering(), llvm::Module::getName(), llvm::hasWholeProgramVisibility(), llvm::heavyweight_hardware_concurrency(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert_range(), llvm::sys::fs::is_directory(), linkCombinedIndex(), LLVM_DEBUG, loadModuleFromInput(), llvm::LTODiscardValueNames, llvm::make_scope_exit(), llvm::Mod, llvm::sys::fs::OF_None, llvm::PrintStatistics(), ProcessThinLTOModule(), llvm::pruneCache(), llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksHotnessThreshold, llvm::RemarksPasses, llvm::RemarksWithHotness, llvm::report_fatal_error(), llvm::reportAndResetTimings(), resolvePrevailingInIndex(), llvm::runWholeProgramDevirtOnIndex(), saveTempBitcode(), llvm::LLVMContext::setDiscardValueNames(), llvm::lto::setupLLVMOptimizationRemarks(), llvm::thinLTOInternalizeAndPromoteInIndex(), llvm::thinLTOPropagateFunctionAttrs(), ThreadCount, llvm::timeTraceProfilerBegin(), llvm::timeTraceProfilerEnabled(), llvm::timeTraceProfilerEnd(), llvm::toString(), llvm::updateIndexWPDForExports(), llvm::updateVCallVisibilityInIndex(), writeGeneratedObject(), and llvm::writeIndexToFile().


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