LLVM  4.0.0
Public Member Functions | Static Public Member Functions | List of all members
llvm::LTOCodeGenerator Struct Reference

C++ class which implements the opaque lto_code_gen_t type. More...

#include <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 (TargetMachine::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 (StringRef 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< MemoryBuffercompile (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< MemoryBuffercompileOptimized ()
 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 setDiagnosticHandler (lto_diagnostic_handler_t, void *)
 
LLVMContextgetContext ()
 
void resetMergedModule ()
 

Static Public Member Functions

static const char * getVersionString ()
 

Detailed Description

C++ class which implements the opaque lto_code_gen_t type.

Definition at line 65 of file LTOCodeGenerator.h.

Constructor & Destructor Documentation

LTOCodeGenerator::LTOCodeGenerator ( LLVMContext Context)
LTOCodeGenerator::~LTOCodeGenerator ( )

Definition at line 114 of file LTOCodeGenerator.cpp.

Member Function Documentation

bool LTOCodeGenerator::addModule ( struct LTOModule Mod)

Merge given module.

Return true on success.

Resets HasVerifiedInput.

Definition at line 151 of file LTOCodeGenerator.cpp.

References assert(), llvm::Module::getContext(), llvm::LTOModule::getModule(), setAsmUndefinedRefs(), and llvm::LTOModule::takeModule().

void llvm::LTOCodeGenerator::addMustPreserveSymbol ( StringRef  Sym)
inline

Definition at line 113 of file LTOCodeGenerator.h.

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 321 of file LTOCodeGenerator.cpp.

References compileOptimized(), and optimize().

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.

Note
It is up to the linker to remove the intermediate output file. Do not try to remove the object file in LTOCodeGenerator's destructor as we don't who (LTOCodeGenerator or the output file) will last longer.

Definition at line 309 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 289 of file LTOCodeGenerator.cpp.

References llvm::ErrorOr< T >::getError(), llvm::MemoryBuffer::getFile(), name, and llvm::sys::fs::remove().

Referenced by compile().

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 582 of file LTOCodeGenerator.cpp.

References llvm::legacy::PassManager::add(), llvm::AreStatisticsEnabled(), llvm::createObjCARCContractPass(), llvm::PrintStatistics(), llvm::legacy::PassManager::run(), and llvm::splitCodeGen().

LLVMContext& llvm::LTOCodeGenerator::getContext ( )
inline

Definition at line 179 of file LTOCodeGenerator.h.

const char * LTOCodeGenerator::getVersionString ( )
static

Definition at line 66 of file LTOCodeGenerator.cpp.

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 537 of file LTOCodeGenerator.cpp.

References llvm::legacy::PassManager::add(), llvm::createFunctionInliningPass(), llvm::createTargetTransformInfoWrapperPass(), llvm::PassManagerBuilder::DisableGVNLoadPRE, and llvm::legacy::PassManager::run().

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 627 of file LTOCodeGenerator.cpp.

References llvm::cl::ParseCommandLineOptions().

void llvm::LTOCodeGenerator::resetMergedModule ( )
inline

Definition at line 181 of file LTOCodeGenerator.h.

void LTOCodeGenerator::setAsmUndefinedRefs ( struct LTOModule Mod)

Definition at line 145 of file LTOCodeGenerator.cpp.

References llvm::LTOModule::getAsmUndefinedRefs(), and i.

Referenced by addModule(), and setModule().

void llvm::LTOCodeGenerator::setAttr ( StringRef  MAttr)
inline

Definition at line 91 of file LTOCodeGenerator.h.

void LTOCodeGenerator::setCodeGenDebugOptions ( StringRef  Options)

Pass options to the driver and optimization passes.

setCodeGenDebugOptions - Set codegen debugging options to aid in debugging LTO problems.

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 621 of file LTOCodeGenerator.cpp.

References llvm::getToken().

void llvm::LTOCodeGenerator::setCodePICModel ( Optional< Reloc::Model Model)
inline

Definition at line 84 of file LTOCodeGenerator.h.

void llvm::LTOCodeGenerator::setCpu ( StringRef  MCpu)
inline

Definition at line 90 of file LTOCodeGenerator.h.

void LTOCodeGenerator::setDebugInfo ( lto_debug_model  Debug)
void LTOCodeGenerator::setDiagnosticHandler ( lto_diagnostic_handler_t  DiagHandler,
void *  Ctxt 
)

Definition at line 674 of file LTOCodeGenerator.cpp.

void llvm::LTOCodeGenerator::setFileType ( TargetMachine::CodeGenFileType  FT)
inline

Set the file type to be emitted (assembly or object code).

The default is TargetMachine::CGFT_ObjectFile.

Definition at line 88 of file LTOCodeGenerator.h.

void LTOCodeGenerator::setModule ( std::unique_ptr< LTOModule M)

Set the destination module.

Resets HasVerifiedInput.

Definition at line 164 of file LTOCodeGenerator.cpp.

References assert(), llvm::StringMap< ValueTy, AllocatorTy >::clear(), and setAsmUndefinedRefs().

void LTOCodeGenerator::setOptLevel ( unsigned  OptLevel)
void llvm::LTOCodeGenerator::setShouldEmbedUselists ( bool  Value)
inline

Definition at line 95 of file LTOCodeGenerator.h.

void llvm::LTOCodeGenerator::setShouldInternalize ( bool  Value)
inline

Definition at line 94 of file LTOCodeGenerator.h.

void llvm::LTOCodeGenerator::setShouldRestoreGlobalsLinkage ( bool  Value)
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 109 of file LTOCodeGenerator.h.

void LTOCodeGenerator::setTargetOptions ( const TargetOptions Options)

Definition at line 178 of file LTOCodeGenerator.cpp.

bool LTOCodeGenerator::writeMergedModules ( StringRef  Path)

Write the merged module to the file specified by the given path.

Return true on success.

Calls verifyMergedModuleOnce().

Definition at line 214 of file LTOCodeGenerator.cpp.

References llvm::raw_fd_ostream::clear_error(), llvm::raw_fd_ostream::close(), llvm::sys::fs::F_None, llvm::raw_fd_ostream::has_error(), llvm::tool_output_file::keep(), llvm::tool_output_file::os(), and llvm::WriteBitcodeToFile().


The documentation for this struct was generated from the following files: