|
LLVM 23.0.0git
|
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 | |
| 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. | |
| LLVM_ABI Error | run (AddStreamFn AddStream, FileCache Cache={}) |
| Runs the LTO pipeline. | |
| 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 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< StringRef > | getLibFuncSymbols (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. | |
Protected Member Functions | |
| virtual Error | serializeInputsForDistribution () |
| virtual void | cleanup () |
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:
| 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 688 of file LTO.cpp.
References llvm::LTOKeepSymbolCopies, and llvm::move().
|
virtualdefault |
References LLVM_ABI.
| 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 822 of file LTO.cpp.
References addInput(), assert(), llvm::lto::Config::ELF, llvm::ArrayRef< T >::empty(), I, llvm::Triple::isOSBinFormatELF(), llvm::Error::success(), llvm::Expected< T >::takeError(), and writeToResolutionFile().
|
inlinevirtual |
|
protectedvirtual |
Reimplemented in llvm::lto::DTLTO.
Definition at line 705 of file LTO.cpp.
References llvm::consumeError(), and llvm::lto::finalizeOptimizationRemarks().
Referenced by llvm::lto::DTLTO::cleanup(), and run().
| void LTO::emitRemark | ( | OptimizationRemark & | Remark | ) |
Helper to emit an optimization remark during the LTO link when outside of the standard optimization pass pipeline.
Definition at line 101 of file LTO.cpp.
References llvm::OptimizationRemarkEmitter::emit(), F, and llvm::Remark.
|
static |
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.
Unlike the runtime libcalls, the linker can report to the code generator which of these are actually available in the link, and the code generator can then only reference that set of symbols.
Definition at line 1506 of file LTO.cpp.
References llvm::StringRef::data(), F, llvm::TargetLibraryInfo::getName(), llvm::TargetLibraryInfo::has(), I, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), and llvm::StringSaver::save().
| 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.
|
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 1493 of file LTO.cpp.
References llvm::StringRef::data(), llvm::RTLIB::RuntimeLibcallsInfo::getLibcallImplName(), llvm::RTLIB::RuntimeLibcallsInfo::getNumAvailableLibcallImpls(), llvm::RTLIB::RuntimeLibcallsInfo::isAvailable(), llvm::RTLIB::libcall_impls(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorImpl< T >::reserve().
| 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 1301 of file LTO.cpp.
References cleanup(), llvm::computeDeadSymbolsWithConstProp(), llvm::GlobalValue::dropLLVMManglingEscape(), llvm::ArrayRef< T >::empty(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), G, llvm::GlobalValue::getGUIDAssumingExternalLinkage(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::No, llvm::PrintStatisticsJSON(), serializeInputsForDistribution(), llvm::lto::setupStatsFile(), llvm::SupportsHotColdNew, llvm::Unknown, and llvm::Yes.
|
inlineprotectedvirtual |
Reimplemented in llvm::lto::DTLTO.
Definition at line 487 of file LTO.h.
References llvm::Error::success().
Referenced by run().
Set the list of functions implemented in bitcode that were not extracted from an archive.
Such functions may not be referenced, as they have lost their opportunity to be defined.
Definition at line 853 of file LTO.cpp.
References assert(), and llvm::ArrayRef< T >::empty().