35#ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
36#define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
89 Config.RelocModel = Model;
97 void setAttrs(std::vector<std::string> MAttrs) {
98 Config.MAttrs = std::move(MAttrs);
105 SaveIRBeforeOptPath = std::move(
Value);
121 ShouldRestoreGlobalsLinkage =
Value;
182 unsigned ParallelismLevel);
204 void verifyMergedModuleOnce();
206 bool compileOptimizedToFile(
const char **Name);
207 void restoreLinkageForExternals();
208 void applyScopeRestrictions();
209 void preserveDiscardableGVs(
213 bool determineTarget();
216 bool useAIXSystemAssembler();
219 void emitError(
const std::string &ErrMsg);
220 void emitWarning(
const std::string &ErrMsg);
222 void finishOptimizationRemarks();
225 std::unique_ptr<Module> MergedModule;
226 std::unique_ptr<Linker> TheLinker;
227 std::unique_ptr<TargetMachine> TargetMach;
228 bool EmitDwarfDebugInfo =
false;
229 bool ScopeRestrictionsDone =
false;
230 bool HasVerifiedInput =
false;
234 std::vector<std::string> CodegenOptions;
235 std::string FeatureStr;
236 std::string NativeObjectPath;
237 const Target *MArch =
nullptr;
239 void *DiagContext =
nullptr;
241 bool ShouldEmbedUselists =
false;
242 bool ShouldRestoreGlobalsLinkage =
false;
244 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
245 std::string SaveIRBeforeOptPath;
This file defines the StringMap class.
static bool mustPreserveGV(const GlobalValue &GV)
Predicate for Internalize pass.
Module.h This file contains the declarations for the Module class.
static std::unique_ptr< TargetMachine > createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M)
StringSet - A set-like wrapper for the StringMap.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is the base abstract class for diagnostic reporting in the backend.
This is an important class for using LLVM in a threaded context.
RAII handle that manages the lifetime of the ToolOutputFile used to output remarks.
This class provides the core functionality of linking in LLVM.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
A Module instance is used to store all the information related to an LLVM module.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
StringSet - A wrapper for StringMap that provides set-like functionality.
Primary interface to the complete machine description for the target machine.
Target - Wrapper for Target specific information.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
void(* lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt)
Diagnostic handler type.
This is an optimization pass for GlobalISel generic memory operations.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
LLVM_ABI cl::opt< bool > EnableLTOInternalization
Enable global value internalization in LTO.
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
std::function< Expected< std::unique_ptr< CachedFileStream > >( unsigned Task, const Twine &ModuleName)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
LLVM_ABI bool optimize()
Optimizes the merged module.
LLVM_ABI std::unique_ptr< MemoryBuffer > compile()
As with compile_to_file(), this function compiles the merged module into single output file.
LLVM_ABI void setModule(std::unique_ptr< LTOModule > M)
Set the destination module.
LLVM_ABI bool compile_to_file(const char **Name)
Compile the merged module into a single output file; the path to output file is returned to the calle...
void setCpu(StringRef MCpu)
void addMustPreserveSymbol(StringRef Sym)
void setShouldInternalize(bool Value)
void setAttrs(std::vector< std::string > MAttrs)
LLVM_ABI void parseCodeGenDebugOptions()
Parse the options set in setCodeGenDebugOptions.
LLVM_ABI void setOptLevel(unsigned OptLevel)
LLVMContext & getContext()
LLVM_ABI void setAsmUndefinedRefs(struct LTOModule *)
LLVM_ABI void setDiagnosticHandler(lto_diagnostic_handler_t, void *)
void setFileType(CodeGenFileType FT)
Set the file type to be emitted (assembly or object code).
LLVM_ABI void setTargetOptions(const TargetOptions &Options)
LLVM_ABI void setCodeGenDebugOptions(ArrayRef< StringRef > Opts)
Pass options to the driver and optimization passes.
LLVM_ABI LTOCodeGenerator(LLVMContext &Context)
void setCodePICModel(std::optional< Reloc::Model > Model)
LLVM_ABI std::unique_ptr< MemoryBuffer > compileOptimized()
Compiles the merged optimized module into a single output file.
void setDebugPassManager(bool Enabled)
LLVM_ABI bool addModule(struct LTOModule *)
Merge given module.
LLVM_ABI void setDebugInfo(lto_debug_model)
void setSaveIRBeforeOptPath(std::string Value)
void setDisableVerify(bool Value)
void setShouldEmbedUselists(bool Value)
LLVM_ABI ~LTOCodeGenerator()
LLVM_ABI bool writeMergedModules(StringRef Path)
Write the merged module to the file specified by the given path.
LLVM_ABI void DiagnosticHandler(const DiagnosticInfo &DI)
static LLVM_ABI const char * getVersionString()
void setShouldRestoreGlobalsLinkage(bool Value)
Restore linkage of globals.
void setFreestanding(bool Enabled)
Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on t...
C++ class which implements the opaque lto_module_t type.