35#ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
36#define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
93 Config.RelocModel = Model;
102 Config.MAttrs = std::move(MAttrs);
109 SaveIRBeforeOptPath = std::move(
Value);
125 ShouldRestoreGlobalsLinkage =
Value;
186 unsigned ParallelismLevel);
208 void verifyMergedModuleOnce();
210 bool compileOptimizedToFile(
const char **Name);
211 void restoreLinkageForExternals();
212 void applyScopeRestrictions();
213 void preserveDiscardableGVs(
217 bool determineTarget();
220 bool useAIXSystemAssembler();
223 void emitError(
const std::string &ErrMsg);
224 void emitWarning(
const std::string &ErrMsg);
226 void finishOptimizationRemarks();
229 std::unique_ptr<Module> MergedModule;
230 std::unique_ptr<Linker> TheLinker;
231 std::unique_ptr<TargetMachine> TargetMach;
232 bool EmitDwarfDebugInfo =
false;
233 bool ScopeRestrictionsDone =
false;
234 bool HasVerifiedInput =
false;
238 std::vector<std::string> CodegenOptions;
239 std::string FeatureStr;
240 std::string NativeObjectPath;
241 const Target *MArch =
nullptr;
243 void *DiagContext =
nullptr;
245 bool ShouldEmbedUselists =
false;
246 bool ShouldRestoreGlobalsLinkage =
false;
248 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
249 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(Function *F, CodeGenOptLevel OptLevel)
Create the TargetMachine object to query the backend for optimization preferences.
StringSet - A set-like wrapper for the StringMap.
static void DiagHandler(const SMDiagnostic &Diag, void *Context)
ArrayRef - 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",...
StringRef - Represent a constant reference to a string, i.e.
StringSet - A wrapper for StringMap that provides set-like functionality.
Provides information about what library functions are available for the current target.
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.
This class implements an extremely fast bulk output stream that can only output to a stream.
An abstract base class for streams implementations that also support a pwrite operation.
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.
LLVM_ABI void parseCommandLineOptions(std::vector< std::string > &Options)
A convenience function that calls cl::ParseCommandLineOptions on the given set of options.
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.