Go to the documentation of this file.
35 #ifndef LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
36 #define LLVM_LTO_LEGACY_LTOCODEGENERATOR_H
56 template <
typename T>
class ArrayRef;
62 class TargetLibraryInfo;
65 class raw_pwrite_stream;
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;
void setCodePICModel(std::optional< Reloc::Model > Model)
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.
cl::opt< bool > EnableLTOInternalization
Enable global value internalization in LTO.
Target - Wrapper for Target specific information.
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.
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).
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.
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.
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)
std::optional< Reloc::Model > RelocModel
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...
CodeGenFileType CGFileType
void setCpu(StringRef MCpu)
void setDebugPassManager(bool Enabled)
void setShouldRestoreGlobalsLinkage(bool Value)
Restore linkage of globals.
ArrayRef(const T &OneElt) -> ArrayRef< T >
void setAsmUndefinedRefs(struct LTOModule *)
void setSaveIRBeforeOptPath(std::string Value)
C++ class which implements the opaque lto_module_t type.
LLVM Value Representation.