|
LLVM
10.0.0
|
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. More... | |
| void | setModule (std::unique_ptr< LTOModule > M) |
| Set the destination module. More... | |
| void | setAsmUndefinedRefs (struct LTOModule *) |
| void | setTargetOptions (const TargetOptions &Options) |
| void | setDebugInfo (lto_debug_model) |
| void | setCodePICModel (Optional< Reloc::Model > Model) |
| void | setFileType (CodeGenFileType FT) |
| Set the file type to be emitted (assembly or object code). More... | |
| void | setCpu (StringRef MCpu) |
| void | setAttr (StringRef MAttr) |
| void | setOptLevel (unsigned OptLevel) |
| void | setShouldInternalize (bool Value) |
| void | setShouldEmbedUselists (bool Value) |
| void | setShouldRestoreGlobalsLinkage (bool Value) |
| Restore linkage of globals. More... | |
| void | addMustPreserveSymbol (StringRef Sym) |
| void | setCodeGenDebugOptions (ArrayRef< const char *> Opts) |
| Pass options to the driver and optimization passes. More... | |
| void | parseCodeGenDebugOptions () |
| Parse the options set in setCodeGenDebugOptions. More... | |
| bool | writeMergedModules (StringRef Path) |
| Write the merged module to the file specified by the given path. More... | |
| bool | compile_to_file (const char **Name, bool DisableVerify, bool DisableInline, bool DisableGVNLoadPRE, bool DisableVectorization) |
| Compile the merged module into a single output file; the path to output file is returned to the caller via argument "name". More... | |
| std::unique_ptr< MemoryBuffer > | compile (bool DisableVerify, bool DisableInline, bool DisableGVNLoadPRE, bool DisableVectorization) |
| As with compile_to_file(), this function compiles the merged module into single output file. More... | |
| bool | optimize (bool DisableVerify, bool DisableInline, bool DisableGVNLoadPRE, bool DisableVectorization) |
| Optimizes the merged module. More... | |
| std::unique_ptr< MemoryBuffer > | compileOptimized () |
| Compiles the merged optimized module into a single output file. More... | |
| bool | compileOptimized (ArrayRef< raw_pwrite_stream *> Out) |
| Compile the merged optimized module into out.size() output files each representing a linkable partition of the module. More... | |
| void | setFreestanding (bool Enabled) |
| Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target. More... | |
| 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 70 of file LTOCodeGenerator.h.
| LTOCodeGenerator::LTOCodeGenerator | ( | LLVMContext & | Context | ) |
Definition at line 111 of file LTOCodeGenerator.cpp.
References llvm::LLVMContext::enableDebugTypeODRUniquing(), llvm::LTODiscardValueNames, and llvm::LLVMContext::setDiscardValueNames().
| LTOCodeGenerator::~LTOCodeGenerator | ( | ) |
Definition at line 119 of file LTOCodeGenerator.cpp.
References llvm::PassRegistry::getPassRegistry(), llvm::initializeArgPromotionPass(), llvm::initializeAttributorLegacyPassPass(), llvm::initializeCFGSimplifyPassPass(), llvm::initializeConstantMergeLegacyPassPass(), llvm::initializeDAHPass(), llvm::initializeDCELegacyPassPass(), llvm::initializeGlobalDCELegacyPassPass(), llvm::initializeGlobalOptLegacyPassPass(), llvm::initializeGlobalsAAWrapperPassPass(), llvm::initializeGVNLegacyPassPass(), llvm::initializeInstructionCombiningPassPass(), llvm::initializeInternalizeLegacyPassPass(), llvm::initializeIPSCCPLegacyPassPass(), llvm::initializeJumpThreadingPass(), llvm::initializeLegacyLICMPassPass(), llvm::initializeMemCpyOptLegacyPassPass(), llvm::initializeMergedLoadStoreMotionLegacyPassPass(), llvm::initializePostOrderFunctionAttrsLegacyPassPass(), llvm::initializePruneEHPass(), llvm::initializeReversePostOrderFunctionAttrsLegacyPassPass(), llvm::initializeSimpleInlinerPass(), and llvm::initializeSROALegacyPassPass().
Merge given module.
Return true on success.
Resets HasVerifiedInput.
Definition at line 157 of file LTOCodeGenerator.cpp.
References assert(), llvm::Module::getContext(), llvm::LTOModule::getModule(), setAsmUndefinedRefs(), and llvm::LTOModule::takeModule().
|
inline |
Definition at line 118 of file LTOCodeGenerator.h.
References compile(), compile_to_file(), compileOptimized(), llvm::StringSet< AllocatorTy >::insert(), Name, optimize(), parseCodeGenDebugOptions(), setCodeGenDebugOptions(), and writeMergedModules().
| std::unique_ptr< MemoryBuffer > LTOCodeGenerator::compile | ( | bool | DisableVerify, |
| bool | DisableInline, | ||
| bool | DisableGVNLoadPRE, | ||
| bool | DisableVectorization | ||
| ) |
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 329 of file LTOCodeGenerator.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_32, llvm::appendToCompilerUsed(), assert(), llvm::SmallVectorImpl< T >::clear(), compileOptimized(), llvm::StringMap< ValueTy, AllocatorTy >::count(), llvm::Target::createTargetMachine(), llvm::dbgs(), llvm::StringMapImpl::empty(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::Module::Error, externalize(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::for_each(), llvm::Triple::getArch(), llvm::SubtargetFeatures::getDefaultSubtargetFeatures(), llvm::sys::getDefaultTargetTriple(), llvm::Mangler::getNameWithPrefix(), llvm::SubtargetFeatures::getString(), I, llvm::StringMap< ValueTy, AllocatorTy >::insert(), llvm::internalizeModule(), llvm::Triple::isOSDarwin(), llvm::TargetRegistry::lookupTarget(), mustPreserveGV(), llvm::None, optimize(), llvm::report_fatal_error(), llvm::SmallVectorImpl< T >::reserve(), llvm::StripDebugInfo(), llvm::updateCompilerUsed(), llvm::verifyModule(), llvm::Triple::x86, and llvm::Triple::x86_64.
Referenced by addMustPreserveSymbol().
| bool LTOCodeGenerator::compile_to_file | ( | const char ** | Name, |
| bool | DisableVerify, | ||
| bool | DisableInline, | ||
| bool | DisableGVNLoadPRE, | ||
| bool | DisableVectorization | ||
| ) |
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 317 of file LTOCodeGenerator.cpp.
References optimize().
Referenced by addMustPreserveSymbol().
| 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 297 of file LTOCodeGenerator.cpp.
References llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), name, and llvm::sys::fs::remove().
Referenced by addMustPreserveSymbol(), compile(), and writeMergedModules().
| bool LTOCodeGenerator::compileOptimized | ( | ArrayRef< raw_pwrite_stream *> | Out | ) |
Compile the merged optimized module into out.size() output files each representing a linkable partition of the module.
If out contains more than one element, code generation is done in parallel with out.size() threads. Output files will be written to members of out. Returns true on success.
Calls verifyMergedModuleOnce().
Definition at line 583 of file LTOCodeGenerator.cpp.
References llvm::legacy::PassManager::add(), llvm::AreStatisticsEnabled(), llvm::createObjCARCContractPass(), llvm::PrintStatistics(), llvm::PrintStatisticsJSON(), llvm::reportAndResetTimings(), llvm::legacy::PassManager::run(), and llvm::splitCodeGen().
| void LTOCodeGenerator::DiagnosticHandler | ( | const DiagnosticInfo & | DI | ) |
Definition at line 642 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().
Referenced by resetMergedModule().
|
inline |
Definition at line 188 of file LTOCodeGenerator.h.
Definition at line 65 of file LTOCodeGenerator.cpp.
References llvm::cl::Hidden, llvm::cl::init(), llvm::LTODiscardValueNames, llvm::LTOStatsFile, NDEBUG, llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksPasses, and llvm::RemarksWithHotness.
| bool LTOCodeGenerator::optimize | ( | bool | DisableVerify, |
| bool | DisableInline, | ||
| bool | DisableGVNLoadPRE, | ||
| bool | DisableVectorization | ||
| ) |
Optimizes the merged module.
Optimize merged modules using various IPO passes.
Returns true on success.
Calls verifyMergedModuleOnce().
Definition at line 522 of file LTOCodeGenerator.cpp.
References llvm::legacy::PassManager::add(), llvm::createFunctionInliningPass(), llvm::createTargetTransformInfoWrapperPass(), llvm::PassManagerBuilder::DisableGVNLoadPRE, llvm::errs(), llvm::LTOStatsFile, llvm::RemarksFilename, llvm::RemarksFormat, llvm::RemarksPasses, llvm::RemarksWithHotness, llvm::report_fatal_error(), llvm::legacy::PassManager::run(), llvm::lto::setupOptimizationRemarks(), llvm::lto::setupStatsFile(), and llvm::toString().
Referenced by addMustPreserveSymbol(), 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 630 of file LTOCodeGenerator.cpp.
References Arg, and llvm::cl::ParseCommandLineOptions().
Referenced by addMustPreserveSymbol().
|
inline |
Definition at line 190 of file LTOCodeGenerator.h.
References llvm::CGFT_ObjectFile, llvm::CodeGenOpt::Default, DiagnosticHandler(), EnableLTOInternalization, and mustPreserveGV().
| void LTOCodeGenerator::setAsmUndefinedRefs | ( | struct LTOModule * | Mod | ) |
Definition at line 151 of file LTOCodeGenerator.cpp.
References llvm::numbers::e, llvm::LTOModule::getAsmUndefinedRefs(), and llvm::StringSet< AllocatorTy >::insert().
Referenced by addModule(), and setModule().
|
inline |
Definition at line 96 of file LTOCodeGenerator.h.
References setOptLevel().
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 625 of file LTOCodeGenerator.cpp.
Referenced by addMustPreserveSymbol().
|
inline |
Definition at line 89 of file LTOCodeGenerator.h.
|
inline |
Definition at line 95 of file LTOCodeGenerator.h.
| void LTOCodeGenerator::setDebugInfo | ( | lto_debug_model | Debug | ) |
Definition at line 188 of file LTOCodeGenerator.cpp.
References llvm_unreachable, LTO_DEBUG_MODEL_DWARF, and LTO_DEBUG_MODEL_NONE.
| void LTOCodeGenerator::setDiagnosticHandler | ( | lto_diagnostic_handler_t | DiagHandler, |
| void * | Ctxt | ||
| ) |
Definition at line 685 of file LTOCodeGenerator.cpp.
References Context, llvm::LLVMContext::diagnose(), llvm::DK_Linker, llvm::DS_Error, llvm::DS_Warning, LTO_DS_ERROR, LTO_DS_WARNING, print(), and llvm::LLVMContext::setDiagnosticHandler().
Referenced by setFreestanding().
|
inline |
Set the file type to be emitted (assembly or object code).
The default is CGFT_ObjectFile.
Definition at line 93 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 184 of file LTOCodeGenerator.h.
References Enabled, and setDiagnosticHandler().
| void LTOCodeGenerator::setModule | ( | std::unique_ptr< LTOModule > | M | ) |
Set the destination module.
Resets HasVerifiedInput.
Definition at line 170 of file LTOCodeGenerator.cpp.
References assert(), llvm::StringMap< ValueTy, AllocatorTy >::clear(), and setAsmUndefinedRefs().
| void LTOCodeGenerator::setOptLevel | ( | unsigned | OptLevel | ) |
Definition at line 201 of file LTOCodeGenerator.cpp.
References llvm::CodeGenOpt::Aggressive, llvm::CodeGenOpt::Default, llvm::CodeGenOpt::Less, llvm_unreachable, and llvm::CodeGenOpt::None.
Referenced by setAttr().
|
inline |
Definition at line 100 of file LTOCodeGenerator.h.
|
inline |
Definition at line 99 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 114 of file LTOCodeGenerator.h.
| void LTOCodeGenerator::setTargetOptions | ( | const TargetOptions & | Options | ) |
Definition at line 184 of file LTOCodeGenerator.cpp.
Write the merged module to the file specified by the given path.
Return true on success.
Calls verifyMergedModuleOnce().
Definition at line 220 of file LTOCodeGenerator.cpp.
References llvm::SmallString< InternalLen >::c_str(), llvm::CGFT_AssemblyFile, llvm::raw_fd_ostream::clear_error(), llvm::raw_fd_ostream::close(), compileOptimized(), llvm::sys::fs::createTemporaryFile(), llvm::raw_fd_ostream::error(), llvm::raw_fd_ostream::has_error(), llvm::ToolOutputFile::keep(), Name, llvm::sys::fs::OF_None, llvm::ToolOutputFile::os(), llvm::sys::fs::remove(), llvm::StringRef::str(), and llvm::WriteBitcodeToFile().
Referenced by addMustPreserveSymbol().
1.8.13