LLVM 20.0.0git
|
C++ class which implements the opaque lto_code_gen_t type. More...
#include "llvm/LTO/legacy/LTOCodeGenerator.h"
Public Member Functions | |
LTOCodeGenerator (LLVMContext &Context) | |
~LTOCodeGenerator () | |
bool | addModule (struct LTOModule *) |
Merge given module. | |
void | setModule (std::unique_ptr< LTOModule > M) |
Set the destination module. | |
void | setAsmUndefinedRefs (struct LTOModule *) |
void | setTargetOptions (const TargetOptions &Options) |
void | setDebugInfo (lto_debug_model) |
void | setCodePICModel (std::optional< Reloc::Model > Model) |
void | setFileType (CodeGenFileType FT) |
Set the file type to be emitted (assembly or object code). | |
void | setCpu (StringRef MCpu) |
void | setAttrs (std::vector< std::string > MAttrs) |
void | setOptLevel (unsigned OptLevel) |
void | setShouldInternalize (bool Value) |
void | setShouldEmbedUselists (bool Value) |
void | setSaveIRBeforeOptPath (std::string Value) |
void | setShouldRestoreGlobalsLinkage (bool Value) |
Restore linkage of globals. | |
void | addMustPreserveSymbol (StringRef Sym) |
void | setCodeGenDebugOptions (ArrayRef< StringRef > Opts) |
Pass options to the driver and optimization passes. | |
void | parseCodeGenDebugOptions () |
Parse the options set in setCodeGenDebugOptions. | |
bool | writeMergedModules (StringRef Path) |
Write the merged module to the file specified by the given path. | |
bool | compile_to_file (const char **Name) |
Compile the merged module into a single output file; the path to output file is returned to the caller via argument "name". | |
std::unique_ptr< MemoryBuffer > | compile () |
As with compile_to_file(), this function compiles the merged module into single output file. | |
bool | optimize () |
Optimizes the merged module. | |
std::unique_ptr< MemoryBuffer > | compileOptimized () |
Compiles the merged optimized module into a single output file. | |
bool | compileOptimized (AddStreamFn AddStream, unsigned ParallelismLevel) |
Compile the merged optimized module ParallelismLevel output files each representing a linkable partition of the module. | |
void | setFreestanding (bool Enabled) |
Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target. | |
void | setDisableVerify (bool Value) |
void | setDebugPassManager (bool Enabled) |
void | setDiagnosticHandler (lto_diagnostic_handler_t, void *) |
LLVMContext & | getContext () |
void | resetMergedModule () |
void | DiagnosticHandler (const DiagnosticInfo &DI) |
Static Public Member Functions | |
static const char * | getVersionString () |
C++ class which implements the opaque lto_code_gen_t type.
Definition at line 72 of file LTOCodeGenerator.h.
LTOCodeGenerator::LTOCodeGenerator | ( | LLVMContext & | Context | ) |
Definition at line 131 of file LTOCodeGenerator.cpp.
References llvm::lto::Config::CodeModel, llvm::lto::Config::CSIRProfile, llvm::LLVMContext::enableDebugTypeODRUniquing(), llvm::LTOCSIRProfile, llvm::LTODiscardValueNames, llvm::LTORunCSIRInstr, llvm::LTOStatsFile, llvm::lto::Config::RunCSIRInstr, llvm::LLVMContext::setDiscardValueNames(), and llvm::lto::Config::StatsFile.
|
default |
Merge given module.
Return true on success.
Resets HasVerifiedInput.
Definition at line 150 of file LTOCodeGenerator.cpp.
References assert(), llvm::Mod, and setAsmUndefinedRefs().
|
inline |
Definition at line 127 of file LTOCodeGenerator.h.
References llvm::StringSet< AllocatorTy >::insert(), and Sym.
std::unique_ptr< MemoryBuffer > LTOCodeGenerator::compile | ( | ) |
As with compile_to_file(), this function compiles the merged module into single output file.
Instead of returning the output file path to the caller (linker), it brings the output to a buffer, and returns the buffer to the caller. This function should delete the intermediate file once its content is brought to memory. Return NULL if the compilation was not successful.
Definition at line 376 of file LTOCodeGenerator.cpp.
References compileOptimized(), and optimize().
Compile the merged module into a single output file; the path to output file is returned to the caller via argument "name".
Return true on success.
Definition at line 369 of file LTOCodeGenerator.cpp.
References Name, and optimize().
std::unique_ptr< MemoryBuffer > LTOCodeGenerator::compileOptimized | ( | ) |
Compiles the merged optimized module into a single output file.
It brings the output to a buffer, and returns the buffer to the caller. Return NULL if the compilation was not successful.
Definition at line 349 of file LTOCodeGenerator.cpp.
References llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), name, and llvm::sys::fs::remove().
Referenced by compile().
bool LTOCodeGenerator::compileOptimized | ( | AddStreamFn | AddStream, |
unsigned | ParallelismLevel | ||
) |
Compile the merged optimized module ParallelismLevel
output files each representing a linkable partition of the module.
If out contains more than one element, code generation is done in parallel with ParallelismLevel
threads. Output files will be written to the streams created using the AddStream
callback. Returns true on success.
Calls verifyMergedModuleOnce().
Definition at line 637 of file LTOCodeGenerator.cpp.
References llvm::AreStatisticsEnabled(), assert(), llvm::lto::Config::CodeGenOnly, llvm::PrintStatistics(), llvm::PrintStatisticsJSON(), and llvm::reportAndResetTimings().
void LTOCodeGenerator::DiagnosticHandler | ( | const DiagnosticInfo & | DI | ) |
Definition at line 692 of file LTOCodeGenerator.cpp.
References assert(), llvm::DS_Error, llvm::DS_Note, llvm::DS_Remark, llvm::DS_Warning, llvm::raw_ostream::flush(), llvm::DiagnosticInfo::getSeverity(), LTO_DS_ERROR, LTO_DS_NOTE, LTO_DS_REMARK, LTO_DS_WARNING, and llvm::DiagnosticInfo::print().
|
inline |
Definition at line 196 of file LTOCodeGenerator.h.
Definition at line 68 of file LTOCodeGenerator.cpp.
bool LTOCodeGenerator::optimize | ( | ) |
Optimizes the merged module.
Optimize merged modules using various IPO passes.
Returns true on success.
Calls verifyMergedModuleOnce().
Definition at line 566 of file LTOCodeGenerator.cpp.
References llvm::errs(), llvm::LTODiscardValueNames, llvm::LTOStatsFile, llvm::sys::fs::OF_None, opt, OS, llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksHotnessThreshold, llvm::RemarksPasses, llvm::RemarksWithHotness, llvm::report_fatal_error(), llvm::LLVMContext::setDiscardValueNames(), llvm::lto::setupLLVMOptimizationRemarks(), llvm::lto::setupStatsFile(), llvm::dwarf::toString(), llvm::updatePublicTypeTestCalls(), llvm::updateVCallVisibilityInModule(), and llvm::WriteBitcodeToFile().
Referenced by compile(), and compile_to_file().
void LTOCodeGenerator::parseCodeGenDebugOptions | ( | ) |
Parse the options set in setCodeGenDebugOptions.
Like setCodeGenDebugOptions(), this must be called before LTOCodeGenerator::compilexxx() and LTOCodeGenerator::writeMergedModules().
Definition at line 677 of file LTOCodeGenerator.cpp.
References llvm::parseCommandLineOptions().
|
inline |
Definition at line 198 of file LTOCodeGenerator.h.
void LTOCodeGenerator::setAsmUndefinedRefs | ( | struct LTOModule * | Mod | ) |
Definition at line 145 of file LTOCodeGenerator.cpp.
References llvm::StringSet< AllocatorTy >::insert(), and llvm::Mod.
Referenced by addModule(), and setModule().
|
inline |
Definition at line 100 of file LTOCodeGenerator.h.
References llvm::lto::Config::MAttrs.
Pass options to the driver and optimization passes.
These options are not necessarily for debugging purpose (the function name is misleading). This function should be called before LTOCodeGenerator::compilexxx(), and LTOCodeGenerator::writeMergedModules().
Definition at line 672 of file LTOCodeGenerator.cpp.
References Options.
|
inline |
Definition at line 91 of file LTOCodeGenerator.h.
References llvm::lto::Config::RelocModel.
|
inline |
Definition at line 99 of file LTOCodeGenerator.h.
References llvm::lto::Config::CPU.
void LTOCodeGenerator::setDebugInfo | ( | lto_debug_model | Debug | ) |
Definition at line 181 of file LTOCodeGenerator.cpp.
References Debug, llvm_unreachable, LTO_DEBUG_MODEL_DWARF, and LTO_DEBUG_MODEL_NONE.
|
inline |
Definition at line 192 of file LTOCodeGenerator.h.
References llvm::lto::Config::DebugPassManager, and Enabled.
void LTOCodeGenerator::setDiagnosticHandler | ( | lto_diagnostic_handler_t | DiagHandler, |
void * | Ctxt | ||
) |
Definition at line 735 of file LTOCodeGenerator.cpp.
References llvm::LLVMContext::setDiagnosticHandler().
|
inline |
Definition at line 190 of file LTOCodeGenerator.h.
References llvm::lto::Config::DisableVerify.
|
inline |
Set the file type to be emitted (assembly or object code).
The default is CodeGenFileType::ObjectFile.
Definition at line 97 of file LTOCodeGenerator.h.
References llvm::lto::Config::CGFileType.
|
inline |
Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target.
Definition at line 188 of file LTOCodeGenerator.h.
References Enabled, and llvm::lto::Config::Freestanding.
void LTOCodeGenerator::setModule | ( | std::unique_ptr< LTOModule > | M | ) |
Set the destination module.
Resets HasVerifiedInput.
Definition at line 163 of file LTOCodeGenerator.cpp.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::clear(), llvm::Mod, and setAsmUndefinedRefs().
void LTOCodeGenerator::setOptLevel | ( | unsigned | OptLevel | ) |
Definition at line 194 of file LTOCodeGenerator.cpp.
References assert(), llvm::lto::Config::CGOptLevel, llvm::CodeGenOpt::getLevel(), llvm::PipelineTuningOptions::LoopVectorization, llvm::lto::Config::OptLevel, llvm::lto::Config::PTO, and llvm::PipelineTuningOptions::SLPVectorization.
|
inline |
Definition at line 107 of file LTOCodeGenerator.h.
|
inline |
Definition at line 106 of file LTOCodeGenerator.h.
|
inline |
Definition at line 105 of file LTOCodeGenerator.h.
|
inline |
Restore linkage of globals.
When set, the linkage of globals will be restored prior to code generation. That is, a global symbol that had external linkage prior to LTO will be emitted with external linkage again; and a local will remain local. Note that this option only affects the end result - globals may still be internalized in the process of LTO and may be modified and/or deleted where legal.
The default behavior will internalize globals (unless on the preserve list) and, if parallel code generation is enabled, will externalize all locals.
Definition at line 123 of file LTOCodeGenerator.h.
void LTOCodeGenerator::setTargetOptions | ( | const TargetOptions & | Options | ) |
Definition at line 177 of file LTOCodeGenerator.cpp.
References llvm::lto::Config::Options, and Options.
Write the merged module to the file specified by the given path.
Return true on success.
Calls verifyMergedModuleOnce().
Definition at line 204 of file LTOCodeGenerator.cpp.
References llvm::raw_fd_ostream::clear_error(), llvm::raw_fd_ostream::close(), llvm::raw_fd_ostream::error(), llvm::raw_fd_ostream::has_error(), llvm::ToolOutputFile::keep(), llvm::sys::fs::OF_None, llvm::ToolOutputFile::os(), and llvm::WriteBitcodeToFile().