LLVM  8.0.1
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 "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 (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 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 *)
 
LLVMContextgetContext ()
 
void resetMergedModule ()
 
void DiagnosticHandler (const DiagnosticInfo &DI)
 

Static Public Member Functions

static const chargetVersionString ()
 

Detailed Description

C++ class which implements the opaque lto_code_gen_t type.

Definition at line 69 of file LTOCodeGenerator.h.

Constructor & Destructor Documentation

◆ LTOCodeGenerator()

LTOCodeGenerator::LTOCodeGenerator ( LLVMContext Context)

◆ ~LTOCodeGenerator()

LTOCodeGenerator::~LTOCodeGenerator ( )

Member Function Documentation

◆ addModule()

bool LTOCodeGenerator::addModule ( struct LTOModule Mod)

Merge given module.

Return true on success.

Resets HasVerifiedInput.

Definition at line 140 of file LTOCodeGenerator.cpp.

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

◆ addMustPreserveSymbol()

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

◆ compile()

std::unique_ptr< MemoryBuffer > LTOCodeGenerator::compile ( bool  DisableVerify,
bool  DisableInline,
bool  DisableGVNLoadPRE,
bool  DisableVectorization 
)

◆ compile_to_file()

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

References optimize().

Referenced by addMustPreserveSymbol().

◆ compileOptimized() [1/2]

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

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

Referenced by addMustPreserveSymbol(), compile(), and writeMergedModules().

◆ compileOptimized() [2/2]

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

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

◆ DiagnosticHandler()

void LTOCodeGenerator::DiagnosticHandler ( const DiagnosticInfo DI)

◆ getContext()

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

Definition at line 187 of file LTOCodeGenerator.h.

◆ getVersionString()

const char * LTOCodeGenerator::getVersionString ( )
static

◆ optimize()

bool LTOCodeGenerator::optimize ( bool  DisableVerify,
bool  DisableInline,
bool  DisableGVNLoadPRE,
bool  DisableVectorization 
)

◆ parseCodeGenDebugOptions()

void LTOCodeGenerator::parseCodeGenDebugOptions ( )

Parse the options set in setCodeGenDebugOptions.

Like setCodeGenDebugOptions(), this must be called before LTOCodeGenerator::compilexxx() and LTOCodeGenerator::writeMergedModules().

Definition at line 600 of file LTOCodeGenerator.cpp.

References Arg, and llvm::cl::ParseCommandLineOptions().

Referenced by addMustPreserveSymbol().

◆ resetMergedModule()

void llvm::LTOCodeGenerator::resetMergedModule ( )
inline

◆ setAsmUndefinedRefs()

void LTOCodeGenerator::setAsmUndefinedRefs ( struct LTOModule Mod)

Definition at line 134 of file LTOCodeGenerator.cpp.

References llvm::LTOModule::getAsmUndefinedRefs().

Referenced by addModule(), and setModule().

◆ setAttr()

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

Definition at line 95 of file LTOCodeGenerator.h.

References setOptLevel().

◆ setCodeGenDebugOptions()

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

References llvm::getToken().

Referenced by addMustPreserveSymbol().

◆ setCodePICModel()

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

Definition at line 88 of file LTOCodeGenerator.h.

◆ setCpu()

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

Definition at line 94 of file LTOCodeGenerator.h.

◆ setDebugInfo()

void LTOCodeGenerator::setDebugInfo ( lto_debug_model  Debug)

◆ setDiagnosticHandler()

void LTOCodeGenerator::setDiagnosticHandler ( lto_diagnostic_handler_t  DiagHandler,
void *  Ctxt 
)

◆ setFileType()

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 92 of file LTOCodeGenerator.h.

◆ setFreestanding()

void llvm::LTOCodeGenerator::setFreestanding ( bool  Enabled)
inline

Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on the target.

Definition at line 183 of file LTOCodeGenerator.h.

References Enabled, and setDiagnosticHandler().

◆ setModule()

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

Set the destination module.

Resets HasVerifiedInput.

Definition at line 153 of file LTOCodeGenerator.cpp.

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

◆ setOptLevel()

void LTOCodeGenerator::setOptLevel ( unsigned  OptLevel)

◆ setShouldEmbedUselists()

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

Definition at line 99 of file LTOCodeGenerator.h.

◆ setShouldInternalize()

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

Definition at line 98 of file LTOCodeGenerator.h.

◆ setShouldRestoreGlobalsLinkage()

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 113 of file LTOCodeGenerator.h.

◆ setTargetOptions()

void LTOCodeGenerator::setTargetOptions ( const TargetOptions Options)

Definition at line 167 of file LTOCodeGenerator.cpp.

◆ writeMergedModules()

bool LTOCodeGenerator::writeMergedModules ( StringRef  Path)

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