struct LTOCodeGenerator

Declaration

struct LTOCodeGenerator { /* full declaration omitted */ };

Description

C++ class which implements the opaque lto_code_gen_t type.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:72

Member Variables

private llvm::LLVMContext& Context
private std::unique_ptr<Module> MergedModule
private std::unique_ptr<Linker> TheLinker
private std::unique_ptr<TargetMachine> TargetMach
private bool EmitDwarfDebugInfo = false
private bool ScopeRestrictionsDone = false
private bool HasVerifiedInput = false
private StringSet<> MustPreserveSymbols
private StringSet<> AsmUndefinedRefs
private StringMap<GlobalValue::LinkageTypes> ExternalSymbols
private std::vector<std::string> CodegenOptions
private std::string FeatureStr
private std::string NativeObjectPath
private const llvm::Target* MArch = nullptr
private std::string TripleStr
private lto_diagnostic_handler_t DiagHandler = nullptr
private void* DiagContext = nullptr
private bool ShouldInternalize = EnableLTOInternalization
private bool ShouldEmbedUselists = false
private bool ShouldRestoreGlobalsLinkage = false
private std::unique_ptr<ToolOutputFile> DiagnosticOutputFile
private std::unique_ptr<ToolOutputFile> StatsFile = nullptr
private std::string SaveIRBeforeOptPath
private lto::Config Config

Method Overview

Methods

void DiagnosticHandler(
    const llvm::DiagnosticInfo& DI)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:197

Parameters

const llvm::DiagnosticInfo& DI

LTOCodeGenerator(llvm::LLVMContext& Context)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:75

Parameters

llvm::LLVMContext& Context

bool addModule(struct LTOModule*)

Description

Merge given module. Return true on success. Resets \a HasVerifiedInput.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:81

Parameters

struct LTOModule*

void addMustPreserveSymbol(llvm::StringRef Sym)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:125

Parameters

llvm::StringRef Sym

void applyScopeRestrictions()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:208

std::unique_ptr<MemoryBuffer> compile()

Description

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.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:163

bool compileOptimized(
    llvm::AddStreamFn AddStream,
    unsigned int ParallelismLevel)

Description

Compile the merged optimized module \p 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 \p ParallelismLevel threads. Output files will be written to the streams created using the \p AddStream callback. Returns true on success. Calls \a verifyMergedModuleOnce().

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:182

Parameters

llvm::AddStreamFn AddStream
unsigned int ParallelismLevel

std::unique_ptr<MemoryBuffer> compileOptimized()

Description

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.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:173

bool compileOptimizedToFile(const char** Name)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:206

Parameters

const char** Name

bool compile_to_file(const char** Name)

Description

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.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:155

Parameters

const char** Name

std::unique_ptr<TargetMachine>
createTargetMachine()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:214

bool determineTarget()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:213

void emitError(const std::string& ErrMsg)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:216

Parameters

const std::string& ErrMsg

void emitWarning(const std::string& ErrMsg)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:217

Parameters

const std::string& ErrMsg

void finishOptimizationRemarks()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:219

llvm::LLVMContext& getContext()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:194

static const char* getVersionString()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:73

bool optimize()

Description

Optimizes the merged module. Returns true on success. Calls \a verifyMergedModuleOnce().

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:168

void parseCodeGenDebugOptions()

Description

Parse the options set in setCodeGenDebugOptions. Like \a setCodeGenDebugOptions(), this must be called before LTOCodeGenerator::compilexxx() and LTOCodeGenerator::writeMergedModules().

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:140

void preserveDiscardableGVs(
    llvm::Module& TheModule,
    llvm::function_ref<bool(const GlobalValue&)>
        mustPreserveGV)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:209

Parameters

llvm::Module& TheModule
llvm::function_ref<bool(const GlobalValue&)> mustPreserveGV

void resetMergedModule()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:196

void restoreLinkageForExternals()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:207

void setAsmUndefinedRefs(struct LTOModule*)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:88

Parameters

struct LTOModule*

void setAttrs(std::vector<std::string> MAttrs)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:100

Parameters

std::vector<std::string> MAttrs

void setCodeGenDebugOptions(
    ArrayRef<llvm::StringRef> Opts)

Description

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().

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:133

Parameters

ArrayRef<llvm::StringRef> Opts

void setCodePICModel(Optional<Reloc::Model> Model)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:91

Parameters

Optional<Reloc::Model> Model

void setCpu(llvm::StringRef MCpu)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:99

Parameters

llvm::StringRef MCpu

void setDebugInfo(lto_debug_model)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:90

Parameters

lto_debug_model

void setDebugPassManager(bool Enabled)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:190

Parameters

bool Enabled

void setDiagnosticHandler(
    lto_diagnostic_handler_t,
    void*)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:192

Parameters

lto_diagnostic_handler_t
void*

void setDisableVerify(bool Value)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:188

Parameters

bool Value

void setFileType(llvm::CodeGenFileType FT)

Description

Set the file type to be emitted (assembly or object code). The default is CGFT_ObjectFile.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:97

Parameters

llvm::CodeGenFileType FT

void setFreestanding(bool Enabled)

Description

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

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:186

Parameters

bool Enabled

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

Description

Set the destination module. Resets \a HasVerifiedInput.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:86

Parameters

std::unique_ptr<LTOModule> M

void setOptLevel(unsigned int OptLevel)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:101

Parameters

unsigned int OptLevel

void setSaveIRBeforeOptPath(std::string Value)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:105

Parameters

std::string Value

void setShouldEmbedUselists(bool Value)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:104

Parameters

bool Value

void setShouldInternalize(bool Value)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:103

Parameters

bool Value

void setShouldRestoreGlobalsLinkage(bool Value)

Description

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.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:121

Parameters

bool Value

void setTargetOptions(
    const llvm::TargetOptions& Options)

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:89

Parameters

const llvm::TargetOptions& Options

void verifyMergedModuleOnce()

Description

Verify the merged module on first call. Sets \a HasVerifiedInput on first call and doesn't run again on the same input.

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:204

bool writeMergedModules(llvm::StringRef Path)

Description

Write the merged module to the file specified by the given path. Return true on success. Calls \a verifyMergedModuleOnce().

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:146

Parameters

llvm::StringRef Path

~LTOCodeGenerator()

Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:76