35#ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
36#define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
62 class TargetLibraryInfo;
65 class raw_pwrite_stream;
87 void setModule(std::unique_ptr<LTOModule> M);
107 SaveIRBeforeOptPath =
Value;
123 ShouldRestoreGlobalsLinkage =
Value;
164 std::unique_ptr<MemoryBuffer>
compile();
205 void verifyMergedModuleOnce();
207 bool compileOptimizedToFile(
const char **
Name);
208 void restoreLinkageForExternals();
209 void applyScopeRestrictions();
210 void preserveDiscardableGVs(
214 bool determineTarget();
215 std::unique_ptr<TargetMachine> createTargetMachine();
217 bool useAIXSystemAssembler();
220 void emitError(
const std::string &ErrMsg);
221 void emitWarning(
const std::string &ErrMsg);
223 void finishOptimizationRemarks();
226 std::unique_ptr<Module> MergedModule;
227 std::unique_ptr<Linker> TheLinker;
228 std::unique_ptr<TargetMachine> TargetMach;
229 bool EmitDwarfDebugInfo =
false;
230 bool ScopeRestrictionsDone =
false;
231 bool HasVerifiedInput =
false;
235 std::vector<std::string> CodegenOptions;
236 std::string FeatureStr;
237 std::string NativeObjectPath;
238 const Target *MArch =
nullptr;
239 std::string TripleStr;
241 void *DiagContext =
nullptr;
243 bool ShouldEmbedUselists =
false;
244 bool ShouldRestoreGlobalsLinkage =
false;
245 std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
246 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
247 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.
This file defines the SmallPtrSet 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.