LLVM 20.0.0git
Classes | Public Member Functions | List of all members
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

void addModule (StringRef Identifier, StringRef Data)
 Add given module to the code generator.
 
void preserveSymbol (StringRef Name)
 Adds to a list of all global symbols that must exist in the final generated code.
 
void crossReferenceSymbol (StringRef Name)
 Adds to a list of all global symbols that are cross-referenced between ThinLTO files.
 
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.
 
std::unique_ptr< ModuleSummaryIndexlinkCombinedIndex ()
 Produce the combined summary index from all the bitcode files: "thin-link".
 
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.
 
void emitImports (Module &Module, StringRef OutputName, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Compute and emit the imported files for module at ModulePath.
 
void crossModuleImport (Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Perform cross-module importing for the module identified by ModuleIdentifier.
 
void gatherImportedSummariesForModule (Module &Module, ModuleSummaryIndex &Index, std::map< std::string, GVSummaryMapTy > &ModuleToSummariesForIndex, GVSummaryPtrSet &DecSummaries, const lto::InputFile &File)
 Compute the list of summaries and the subset of declaration summaries needed for importing into module.
 
void internalize (Module &Module, ModuleSummaryIndex &Index, const lto::InputFile &File)
 Perform internalization.
 
void optimize (Module &Module)
 Perform post-importing ThinLTO optimizations.
 
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 52 of file ThinLTOCodeGenerator.h.

Member Function Documentation

◆ addModule()

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

◆ 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 573 of file ThinLTOCodeGenerator.cpp.

References llvm::StringSet< AllocatorTy >::insert(), and Name.

◆ 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 87 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 96 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 569 of file ThinLTOCodeGenerator.cpp.

References llvm::StringSet< AllocatorTy >::insert(), and Name.

◆ 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 963 of file ThinLTOCodeGenerator.cpp.

References llvm::AreStatisticsEnabled(), assert(), llvm::ThreadPoolInterface::async(), llvm::ComputeCrossModuleImport(), computeDeadSymbolsInIndex(), llvm::computeSyntheticCounts(), llvm::count(), llvm::TargetMachineBuilder::create(), llvm::sys::fs::create_directories(), llvm::dbgs(), llvm::StringRef::empty(), llvm::LLVMContext::enableDebugTypeODRUniquing(), llvm::errs(), llvm::lto::generateModulesOrdering(), llvm::Module::getName(), llvm::hasWholeProgramVisibility(), llvm::heavyweight_hardware_concurrency(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::sys::fs::is_directory(), linkCombinedIndex(), LLVM_DEBUG, llvm::LTODiscardValueNames, llvm::make_scope_exit(), llvm::Mod, llvm::sys::fs::OF_None, OS, llvm::ThinLTOCodeGenerator::CachingOptions::Path, llvm::ThinLTOCodeGenerator::CachingOptions::Policy, llvm::PrintStatistics(), llvm::pruneCache(), llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksHotnessThreshold, llvm::RemarksPasses, llvm::RemarksWithHotness, llvm::report_fatal_error(), llvm::reportAndResetTimings(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::reserve(), llvm::runWholeProgramDevirtOnIndex(), llvm::LLVMContext::setDiscardValueNames(), llvm::lto::setupLLVMOptimizationRemarks(), llvm::TargetMachineBuilder::TheTriple, llvm::thinLTOInternalizeAndPromoteInIndex(), llvm::thinLTOPropagateFunctionAttrs(), llvm::timeTraceProfilerBegin(), llvm::timeTraceProfilerEnabled(), llvm::timeTraceProfilerEnd(), llvm::dwarf::toString(), llvm::updateIndexWPDForExports(), llvm::updateVCallVisibilityInIndex(), writeGeneratedObject(), and llvm::writeIndexToFile().


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