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
- public void DiagnosticHandler(const llvm::DiagnosticInfo & DI)
- public LTOCodeGenerator(llvm::LLVMContext & Context)
- public bool addModule(struct LTOModule *)
- public void addMustPreserveSymbol(llvm::StringRef Sym)
- private void applyScopeRestrictions()
- public std::unique_ptr<MemoryBuffer> compile()
- public bool compileOptimized(llvm::AddStreamFn AddStream, unsigned int ParallelismLevel)
- public std::unique_ptr<MemoryBuffer> compileOptimized()
- private bool compileOptimizedToFile(const char ** Name)
- public bool compile_to_file(const char ** Name)
- private std::unique_ptr<TargetMachine> createTargetMachine()
- private bool determineTarget()
- private void emitError(const std::string & ErrMsg)
- private void emitWarning(const std::string & ErrMsg)
- private void finishOptimizationRemarks()
- public llvm::LLVMContext & getContext()
- public static const char * getVersionString()
- public bool optimize()
- public void parseCodeGenDebugOptions()
- private void preserveDiscardableGVs(llvm::Module & TheModule, llvm::function_ref<bool (const GlobalValue &)> mustPreserveGV)
- public void resetMergedModule()
- private void restoreLinkageForExternals()
- public void setAsmUndefinedRefs(struct LTOModule *)
- public void setAttrs(std::vector<std::string> MAttrs)
- public void setCodeGenDebugOptions(ArrayRef<llvm::StringRef> Opts)
- public void setCodePICModel(Optional<Reloc::Model> Model)
- public void setCpu(llvm::StringRef MCpu)
- public void setDebugInfo(lto_debug_model)
- public void setDebugPassManager(bool Enabled)
- public void setDiagnosticHandler(lto_diagnostic_handler_t, void *)
- public void setDisableVerify(bool Value)
- public void setFileType(llvm::CodeGenFileType FT)
- public void setFreestanding(bool Enabled)
- public void setModule(std::unique_ptr<LTOModule> M)
- public void setOptLevel(unsigned int OptLevel)
- public void setSaveIRBeforeOptPath(std::string Value)
- public void setShouldEmbedUselists(bool Value)
- public void setShouldInternalize(bool Value)
- public void setShouldRestoreGlobalsLinkage(bool Value)
- public void setTargetOptions(const llvm::TargetOptions & Options)
- private void verifyMergedModuleOnce()
- public bool writeMergedModules(llvm::StringRef Path)
- public ~LTOCodeGenerator()
Methods
¶void DiagnosticHandler(
const llvm::DiagnosticInfo& DI)
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)
LTOCodeGenerator(llvm::LLVMContext& Context)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:75
Parameters
- llvm::LLVMContext& Context
¶bool addModule(struct LTOModule*)
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)
void addMustPreserveSymbol(llvm::StringRef Sym)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:125
Parameters
- llvm::StringRef Sym
¶void applyScopeRestrictions()
void applyScopeRestrictions()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:208
¶std::unique_ptr<MemoryBuffer> compile()
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)
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()
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)
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)
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()
std::unique_ptr<TargetMachine>
createTargetMachine()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:214
¶bool determineTarget()
bool determineTarget()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:213
¶void emitError(const std::string& ErrMsg)
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)
void emitWarning(const std::string& ErrMsg)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:217
Parameters
- const std::string& ErrMsg
¶void finishOptimizationRemarks()
void finishOptimizationRemarks()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:219
¶llvm::LLVMContext& getContext()
llvm::LLVMContext& getContext()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:194
¶static const char* getVersionString()
static const char* getVersionString()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:73
¶bool optimize()
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()
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)
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()
void resetMergedModule()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:196
¶void restoreLinkageForExternals()
void restoreLinkageForExternals()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:207
¶void setAsmUndefinedRefs(struct LTOModule*)
void setAsmUndefinedRefs(struct LTOModule*)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:88
Parameters
- struct LTOModule*
¶void setAttrs(std::vector<std::string> MAttrs)
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)
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)
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)
void setCpu(llvm::StringRef MCpu)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:99
Parameters
- llvm::StringRef MCpu
¶void setDebugInfo(lto_debug_model)
void setDebugInfo(lto_debug_model)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:90
Parameters
- lto_debug_model
¶void setDebugPassManager(bool Enabled)
void setDebugPassManager(bool Enabled)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:190
Parameters
- bool Enabled
¶void setDiagnosticHandler(
lto_diagnostic_handler_t,
void*)
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)
void setDisableVerify(bool Value)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:188
Parameters
- bool Value
¶void setFileType(llvm::CodeGenFileType FT)
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)
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)
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)
void setOptLevel(unsigned int OptLevel)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:101
Parameters
- unsigned int OptLevel
¶void setSaveIRBeforeOptPath(std::string Value)
void setSaveIRBeforeOptPath(std::string Value)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:105
Parameters
- std::string Value
¶void setShouldEmbedUselists(bool Value)
void setShouldEmbedUselists(bool Value)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:104
Parameters
- bool Value
¶void setShouldInternalize(bool Value)
void setShouldInternalize(bool Value)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:103
Parameters
- bool Value
¶void setShouldRestoreGlobalsLinkage(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)
void setTargetOptions(
const llvm::TargetOptions& Options)
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:89
Parameters
- const llvm::TargetOptions& Options
¶void verifyMergedModuleOnce()
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)
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()
~LTOCodeGenerator()
Declared at: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h:76