LLVM 22.0.0git
|
C++ class which implements the opaque lto_code_gen_t type. More...
#include "llvm/LTO/legacy/LTOCodeGenerator.h"
Public Member Functions | |
LLVM_ABI | LTOCodeGenerator (LLVMContext &Context) |
LLVM_ABI | ~LTOCodeGenerator () |
LLVM_ABI bool | addModule (struct LTOModule *) |
Merge given module. | |
LLVM_ABI void | setModule (std::unique_ptr< LTOModule > M) |
Set the destination module. | |
LLVM_ABI void | setAsmUndefinedRefs (struct LTOModule *) |
LLVM_ABI void | setTargetOptions (const TargetOptions &Options) |
LLVM_ABI 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) |
LLVM_ABI 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) |
LLVM_ABI void | setCodeGenDebugOptions (ArrayRef< StringRef > Opts) |
Pass options to the driver and optimization passes. | |
LLVM_ABI void | parseCodeGenDebugOptions () |
Parse the options set in setCodeGenDebugOptions. | |
LLVM_ABI bool | writeMergedModules (StringRef Path) |
Write the merged module to the file specified by the given path. | |
LLVM_ABI 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". | |
LLVM_ABI std::unique_ptr< MemoryBuffer > | compile () |
As with compile_to_file(), this function compiles the merged module into single output file. | |
LLVM_ABI bool | optimize () |
Optimizes the merged module. | |
LLVM_ABI std::unique_ptr< MemoryBuffer > | compileOptimized () |
Compiles the merged optimized module into a single output file. | |
LLVM_ABI 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) |
LLVM_ABI void | setDiagnosticHandler (lto_diagnostic_handler_t, void *) |
LLVMContext & | getContext () |
void | resetMergedModule () |
LLVM_ABI void | DiagnosticHandler (const DiagnosticInfo &DI) |
Static Public Member Functions | |
static LLVM_ABI const char * | getVersionString () |
C++ class which implements the opaque lto_code_gen_t type.
Definition at line 73 of file LTOCodeGenerator.h.
LTOCodeGenerator::LTOCodeGenerator | ( | LLVMContext & | Context | ) |
Definition at line 123 of file LTOCodeGenerator.cpp.
References llvm::LTOCSIRProfile, llvm::LTODiscardValueNames, llvm::LTORunCSIRInstr, and llvm::LTOStatsFile.
Merge given module.
Return true on success.
Resets HasVerifiedInput.
Definition at line 141 of file LTOCodeGenerator.cpp.
References assert(), llvm::Mod, and setAsmUndefinedRefs().
|
inline |
Definition at line 128 of file LTOCodeGenerator.h.
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 367 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 360 of file LTOCodeGenerator.cpp.
References 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 340 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 628 of file LTOCodeGenerator.cpp.
References llvm::AreStatisticsEnabled(), assert(), llvm::PrintStatistics(), llvm::PrintStatisticsJSON(), and llvm::reportAndResetTimings().
void LTOCodeGenerator::DiagnosticHandler | ( | const DiagnosticInfo & | DI | ) |
Definition at line 683 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 198 of file LTOCodeGenerator.h.
Definition at line 61 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 557 of file LTOCodeGenerator.cpp.
References llvm::errs(), llvm::LTODiscardValueNames, llvm::LTOStatsFile, llvm::sys::fs::OF_None, llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksHotnessThreshold, llvm::RemarksPasses, llvm::RemarksWithHotness, llvm::report_fatal_error(), llvm::lto::setupLLVMOptimizationRemarks(), llvm::lto::setupStatsFile(), llvm::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 668 of file LTOCodeGenerator.cpp.
References llvm::parseCommandLineOptions().
|
inline |
Definition at line 200 of file LTOCodeGenerator.h.
void LTOCodeGenerator::setAsmUndefinedRefs | ( | struct LTOModule * | Mod | ) |
Definition at line 137 of file LTOCodeGenerator.cpp.
References llvm::Mod.
Referenced by addModule(), and setModule().
|
inline |
Definition at line 101 of file LTOCodeGenerator.h.
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 663 of file LTOCodeGenerator.cpp.
References Options.
|
inline |
Definition at line 92 of file LTOCodeGenerator.h.
|
inline |
Definition at line 100 of file LTOCodeGenerator.h.
void LTOCodeGenerator::setDebugInfo | ( | lto_debug_model | Debug | ) |
Definition at line 172 of file LTOCodeGenerator.cpp.
References Debug, llvm_unreachable, LTO_DEBUG_MODEL_DWARF, and LTO_DEBUG_MODEL_NONE.
|
inline |
Definition at line 194 of file LTOCodeGenerator.h.
References Enabled.
void LTOCodeGenerator::setDiagnosticHandler | ( | lto_diagnostic_handler_t | DiagHandler, |
void * | Ctxt ) |
Definition at line 726 of file LTOCodeGenerator.cpp.
|
inline |
Definition at line 192 of file LTOCodeGenerator.h.
|
inline |
Set the file type to be emitted (assembly or object code).
The default is CodeGenFileType::ObjectFile.
Definition at line 98 of file LTOCodeGenerator.h.
|
inline |
Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target.
Definition at line 190 of file LTOCodeGenerator.h.
References Enabled.
void LTOCodeGenerator::setModule | ( | std::unique_ptr< LTOModule > | M | ) |
Set the destination module.
Resets HasVerifiedInput.
Definition at line 154 of file LTOCodeGenerator.cpp.
References assert(), llvm::Mod, and setAsmUndefinedRefs().
void LTOCodeGenerator::setOptLevel | ( | unsigned | OptLevel | ) |
Definition at line 185 of file LTOCodeGenerator.cpp.
References assert(), and llvm::CodeGenOpt::getLevel().
|
inline |
Definition at line 108 of file LTOCodeGenerator.h.
|
inline |
Definition at line 107 of file LTOCodeGenerator.h.
|
inline |
Definition at line 106 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 124 of file LTOCodeGenerator.h.
void LTOCodeGenerator::setTargetOptions | ( | const TargetOptions & | Options | ) |
Definition at line 168 of file LTOCodeGenerator.cpp.
References Options.
Write the merged module to the file specified by the given path.
Return true on success.
Calls verifyMergedModuleOnce().
Definition at line 195 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().