35#ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
36#define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
61 class TargetLibraryInfo;
64 class raw_pwrite_stream;
86 void setModule(std::unique_ptr<LTOModule> M);
101 Config.
MAttrs = std::move(MAttrs);
108 SaveIRBeforeOptPath = std::move(
Value);
124 ShouldRestoreGlobalsLinkage =
Value;
165 std::unique_ptr<MemoryBuffer>
compile();
206 void verifyMergedModuleOnce();
208 bool compileOptimizedToFile(
const char **
Name);
209 void restoreLinkageForExternals();
210 void applyScopeRestrictions();
211 void preserveDiscardableGVs(
215 bool determineTarget();
216 std::unique_ptr<TargetMachine> createTargetMachine();
218 bool useAIXSystemAssembler();
221 void emitError(
const std::string &ErrMsg);
222 void emitWarning(
const std::string &ErrMsg);
224 void finishOptimizationRemarks();
227 std::unique_ptr<Module> MergedModule;
228 std::unique_ptr<Linker> TheLinker;
229 std::unique_ptr<TargetMachine> TargetMach;
230 bool EmitDwarfDebugInfo =
false;
231 bool ScopeRestrictionsDone =
false;
232 bool HasVerifiedInput =
false;
236 std::vector<std::string> CodegenOptions;
237 std::string FeatureStr;
238 std::string NativeObjectPath;
239 const Target *MArch =
nullptr;
240 std::string TripleStr;
242 void *DiagContext =
nullptr;
244 bool ShouldEmbedUselists =
false;
245 bool ShouldRestoreGlobalsLinkage =
false;
246 std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
247 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
248 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.
StringSet - A set-like wrapper for the StringMap.
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.
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.
std::pair< typename Base::iterator, bool > insert(StringRef key)
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.
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.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
cl::opt< bool > EnableLTOInternalization
Enable global value internalization in LTO.
void parseCommandLineOptions(std::vector< std::string > &Options)
A convenience function that calls cl::ParseCommandLineOptions on the given set of options.
ArrayRef(const T &OneElt) -> ArrayRef< T >
This is the base class for diagnostic handling in LLVM.
C++ class which implements the opaque lto_code_gen_t type.
bool optimize()
Optimizes the merged module.
std::unique_ptr< MemoryBuffer > compile()
As with compile_to_file(), this function compiles the merged module into single output file.
void setModule(std::unique_ptr< LTOModule > M)
Set the destination module.
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)
void parseCodeGenDebugOptions()
Parse the options set in setCodeGenDebugOptions.
void setOptLevel(unsigned OptLevel)
LLVMContext & getContext()
void setAsmUndefinedRefs(struct LTOModule *)
void setDiagnosticHandler(lto_diagnostic_handler_t, void *)
void setFileType(CodeGenFileType FT)
Set the file type to be emitted (assembly or object code).
void setTargetOptions(const TargetOptions &Options)
void setCodeGenDebugOptions(ArrayRef< StringRef > Opts)
Pass options to the driver and optimization passes.
void setCodePICModel(std::optional< Reloc::Model > Model)
std::unique_ptr< MemoryBuffer > compileOptimized()
Compiles the merged optimized module into a single output file.
void setDebugPassManager(bool Enabled)
bool addModule(struct LTOModule *)
Merge given module.
void setDebugInfo(lto_debug_model)
void setSaveIRBeforeOptPath(std::string Value)
void setDisableVerify(bool Value)
void setShouldEmbedUselists(bool Value)
bool writeMergedModules(StringRef Path)
Write the merged module to the file specified by the given path.
static 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.
bool DebugPassManager
Whether to emit the pass manager debuggging informations.
std::vector< std::string > MAttrs
std::optional< Reloc::Model > RelocModel
CodeGenFileType CGFileType
bool Freestanding
Flag to indicate that the optimizer should not assume builtins are present on the target.