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);
106 SaveIRBeforeOptPath =
Value;
122 ShouldRestoreGlobalsLinkage =
Value;
163 std::unique_ptr<MemoryBuffer>
compile();
204 void verifyMergedModuleOnce();
206 bool compileOptimizedToFile(
const char **
Name);
207 void restoreLinkageForExternals();
208 void applyScopeRestrictions();
209 void preserveDiscardableGVs(
213 bool determineTarget();
214 std::unique_ptr<TargetMachine> createTargetMachine();
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;
238 std::string TripleStr;
240 void *DiagContext =
nullptr;
242 bool ShouldEmbedUselists =
false;
243 bool ShouldRestoreGlobalsLinkage =
false;
244 std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
245 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
246 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.