Go to the documentation of this file.
34 #ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
35 #define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
58 template <
typename T>
class ArrayRef;
64 class TargetLibraryInfo;
67 class raw_pwrite_stream;
119 ShouldRestoreGlobalsLinkage =
Value;
160 std::unique_ptr<MemoryBuffer>
compile();
201 void verifyMergedModuleOnce();
203 bool compileOptimizedToFile(
const char **
Name);
204 void restoreLinkageForExternals();
205 void applyScopeRestrictions();
206 void preserveDiscardableGVs(
210 bool determineTarget();
211 std::unique_ptr<TargetMachine> createTargetMachine();
213 void emitError(
const std::string &ErrMsg);
214 void emitWarning(
const std::string &ErrMsg);
216 void finishOptimizationRemarks();
219 std::unique_ptr<Module> MergedModule;
220 std::unique_ptr<Linker> TheLinker;
221 std::unique_ptr<TargetMachine> TargetMach;
222 bool EmitDwarfDebugInfo =
false;
223 bool ScopeRestrictionsDone =
false;
224 bool HasVerifiedInput =
false;
228 std::vector<std::string> CodegenOptions;
229 std::string FeatureStr;
230 std::string NativeObjectPath;
231 const Target *MArch =
nullptr;
232 std::string TripleStr;
234 void *DiagContext =
nullptr;
236 bool ShouldEmbedUselists =
false;
237 bool ShouldRestoreGlobalsLinkage =
false;
238 std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
239 std::unique_ptr<ToolOutputFile> StatsFile =
nullptr;
LLVMContext & getContext()
void setCodeGenDebugOptions(ArrayRef< StringRef > Opts)
Pass options to the driver and optimization passes.
void setDiagnosticHandler(lto_diagnostic_handler_t, void *)
This is an optimization pass for GlobalISel generic memory operations.
static bool mustPreserveGV(const GlobalValue &GV)
Predicate for Internalize pass.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void parseCodeGenDebugOptions()
Parse the options set in setCodeGenDebugOptions.
Target - Wrapper for Target specific information.
std::function< Expected< std::unique_ptr< CachedFileStream > >(unsigned Task)> AddStreamFn
This type defines the callback to add a file that is generated on the fly.
LTOCodeGenerator(LLVMContext &Context)
void setDebugInfo(lto_debug_model)
void setTargetOptions(const TargetOptions &Options)
bool Freestanding
Flag to indicate that the optimizer should not assume builtins are present on the target.
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 setShouldEmbedUselists(bool Value)
std::pair< typename Base::iterator, bool > insert(StringRef key)
void setOptLevel(unsigned OptLevel)
bool addModule(struct LTOModule *)
Merge given module.
std::unique_ptr< MemoryBuffer > compile()
As with compile_to_file(), this function compiles the merged module into single output file.
void setCodePICModel(Optional< Reloc::Model > Model)
std::unique_ptr< MemoryBuffer > compileOptimized()
Compiles the merged optimized module into a single output file.
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
bool optimize()
Optimizes the merged module.
This is the base abstract class for diagnostic reporting in the backend.
void setAttrs(std::vector< std::string > MAttrs)
bool DebugPassManager
Whether to emit the pass manager debuggging informations.
void setShouldInternalize(bool Value)
void DiagnosticHandler(const DiagnosticInfo &DI)
An efficient, type-erasing, non-owning reference to a callable.
static const char * getVersionString()
void parseCommandLineOptions(std::vector< std::string > &Options)
A convenience function that calls cl::ParseCommandLineOptions on the given set of options.
void setDisableVerify(bool Value)
This is an important class for using LLVM in a threaded context.
C++ class which implements the opaque lto_code_gen_t type.
void setFileType(CodeGenFileType FT)
Set the file type to be emitted (assembly or object code).
void(* lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt)
Diagnostic handler type.
std::vector< std::string > MAttrs
A Module instance is used to store all the information related to an LLVM module.
StringSet - A wrapper for StringMap that provides set-like functionality.
void setModule(std::unique_ptr< LTOModule > M)
Set the destination module.
Optional< Reloc::Model > RelocModel
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
StringRef - Represent a constant reference to a string, i.e.
void addMustPreserveSymbol(StringRef Sym)
bool writeMergedModules(StringRef Path)
Write the merged module to the file specified by the given path.
void setFreestanding(bool Enabled)
Enable the Freestanding mode: indicate that the optimizer should not assume builtins are present on t...
llvm::cl::opt< bool > EnableLTOInternalization
Enable global value internalization in LTO.
CodeGenFileType CGFileType
void setCpu(StringRef MCpu)
void setDebugPassManager(bool Enabled)
void setShouldRestoreGlobalsLinkage(bool Value)
Restore linkage of globals.
void setAsmUndefinedRefs(struct LTOModule *)
C++ class which implements the opaque lto_module_t type.
LLVM Value Representation.