LLVM 20.0.0git
|
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< ModuleSummaryIndex > | linkCombinedIndex () |
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, ModuleToSummariesForIndexTy &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. | |
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 59 of file ThinLTOCodeGenerator.h.
Add given module to the code generator.
Definition at line 544 of file ThinLTOCodeGenerator.cpp.
References llvm::lto::InputFile::create(), llvm::Data, initTMBuilder(), llvm::Triple::isCompatibleWith(), llvm::Triple::merge(), llvm::report_fatal_error(), llvm::ThinLTOCodeGeneratorImpl::TargetMachineBuilder::TheTriple, and llvm::toString().
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 571 of file ThinLTOCodeGenerator.cpp.
References llvm::StringSet< AllocatorTy >::insert(), and Name.
|
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 94 of file ThinLTOCodeGenerator.h.
|
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 103 of file ThinLTOCodeGenerator.h.
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 567 of file ThinLTOCodeGenerator.cpp.
References llvm::StringSet< AllocatorTy >::insert(), and Name.
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 960 of file ThinLTOCodeGenerator.cpp.
References addUsedSymbolToPreservedGUID(), llvm::AreStatisticsEnabled(), assert(), llvm::ThreadPoolInterface::async(), codegenModule(), llvm::ComputeCrossModuleImport(), computeDeadSymbolsInIndex(), computeGUIDPreservedSymbols(), computePrevailingCopies(), llvm::count(), llvm::ThinLTOCodeGeneratorImpl::TargetMachineBuilder::create(), llvm::sys::fs::create_directories(), llvm::dbgs(), llvm::LLVMContext::enableDebugTypeODRUniquing(), llvm::errs(), generateModuleMap(), 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, loadModuleFromInput(), llvm::LTODiscardValueNames, llvm::make_scope_exit(), llvm::Mod, llvm::sys::fs::OF_None, OS, llvm::ThinLTOCodeGenerator::CachingOptions::Path, llvm::ThinLTOCodeGenerator::CachingOptions::Policy, llvm::PrintStatistics(), ProcessThinLTOModule(), 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(), resolvePrevailingInIndex(), llvm::runWholeProgramDevirtOnIndex(), saveTempBitcode(), llvm::LLVMContext::setDiscardValueNames(), llvm::lto::setupLLVMOptimizationRemarks(), llvm::ThinLTOCodeGeneratorImpl::TargetMachineBuilder::TheTriple, llvm::thinLTOInternalizeAndPromoteInIndex(), llvm::thinLTOPropagateFunctionAttrs(), ThreadCount, llvm::timeTraceProfilerBegin(), llvm::timeTraceProfilerEnabled(), llvm::timeTraceProfilerEnd(), llvm::toString(), llvm::updateIndexWPDForExports(), llvm::updateVCallVisibilityInIndex(), writeGeneratedObject(), and llvm::writeIndexToFile().