LLVM: llvm::MCJIT Class Reference (original) (raw)
#include "[ExecutionEngine/MCJIT/MCJIT.h](lib%5F2ExecutionEngine%5F2MCJIT%5F2MCJIT%5F8h%5Fsource.html)"
| Public Member Functions | |
|---|---|
| ~MCJIT () override | |
| ExecutionEngine interface implementation | |
| void | addModule (std::unique_ptr< Module > M) override |
| Add a Module to the list of modules that we can JIT from. | |
| void | addObjectFile (std::unique_ptr< object::ObjectFile > O) override |
| addObjectFile - Add an ObjectFile to the execution engine. | |
| void | addObjectFile (object::OwningBinary< object::ObjectFile > O) override |
| void | addArchive (object::OwningBinary< object::Archive > O) override |
| addArchive - Add an Archive to the execution engine. | |
| bool | removeModule (Module *M) override |
| removeModule - Removes a Module from the list of modules, but does not free the module's memory. | |
| Function * | FindFunctionNamed (StringRef FnName) override |
| FindFunctionNamed - Search all of the active modules to find the function that defines FnName. | |
| GlobalVariable * | FindGlobalVariableNamed (StringRef Name, bool AllowInternal=false) override |
| FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name. | |
| void | setObjectCache (ObjectCache *manager) override |
| Sets the object manager that MCJIT should use to avoid compilation. | |
| void | setProcessAllSections (bool ProcessAllSections) override |
| setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded. | |
| void | generateCodeForModule (Module *M) override |
| generateCodeForModule - Run code generation for the specified module and load it into memory. | |
| void | finalizeObject () override |
| finalizeObject - ensure the module is fully processed and is usable. | |
| virtual void | finalizeModule (Module *) |
| void | finalizeLoadedModules () |
| void | runStaticConstructorsDestructors (bool isDtors) override |
| runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program. | |
| void * | getPointerToFunction (Function *F) override |
| getPointerToFunction - The different EE's represent function bodies in different ways. | |
| GenericValue | runFunction (Function *F, ArrayRef< GenericValue > ArgValues) override |
| runFunction - Execute the specified function with the specified arguments, and return the result. | |
| void * | getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override |
| getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. | |
| void | mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) override |
| mapSectionAddress - map a section to its target address space value. | |
| void | RegisterJITEventListener (JITEventListener *L) override |
| Registers a listener to be called back on various events within the JIT. | |
| void | UnregisterJITEventListener (JITEventListener *L) override |
| uint64_t | getGlobalValueAddress (const std::string &Name) override |
| getGlobalValueAddress - Return the address of the specified global value. | |
| uint64_t | getFunctionAddress (const std::string &Name) override |
| getFunctionAddress - Return the address of the specified function. | |
| TargetMachine * | getTargetMachine () override |
| Return the target machine (if available). | |
| Public Member Functions inherited from llvm::ExecutionEngine | |
| virtual | ~ExecutionEngine () |
| const DataLayout & | getDataLayout () const |
| bool | hasError () const |
| Returns true if an error has been recorded. | |
| void | clearErrorMessage () |
| Clear the error message. | |
| const std::string & | getErrorMessage () const |
| Returns the most recent error message. | |
| void | runStaticConstructorsDestructors (Module &module, bool isDtors) |
| This method is used to execute all of the static constructors or destructors for a particular module. | |
| int | runFunctionAsMain (Function *Fn, const std::vector< std::string > &argv, const char *const *envp) |
| runFunctionAsMain - This is a helper function which wraps runFunction to handle the common task of starting up main with the specified argc, argv, and envp parameters. | |
| void | addGlobalMapping (const GlobalValue *GV, void *Addr) |
| addGlobalMapping - Tell the execution engine that the specified global is at the specified location. | |
| void | addGlobalMapping (StringRef Name, uint64_t Addr) |
| void | clearAllGlobalMappings () |
| clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals. | |
| void | clearGlobalMappingsFromModule (Module *M) |
| clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT. | |
| uint64_t | updateGlobalMapping (const GlobalValue *GV, void *Addr) |
| updateGlobalMapping - Replace an existing mapping for GV with a new address. | |
| uint64_t | updateGlobalMapping (StringRef Name, uint64_t Addr) |
| uint64_t | getAddressToGlobalIfAvailable (StringRef S) |
| getAddressToGlobalIfAvailable - This returns the address of the specified global symbol. | |
| void * | getPointerToGlobalIfAvailable (StringRef S) |
| getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has already been codegen'd, otherwise it returns null. | |
| void * | getPointerToGlobalIfAvailable (const GlobalValue *GV) |
| void * | getPointerToGlobal (const GlobalValue *GV) |
| getPointerToGlobal - This returns the address of the specified global value. | |
| virtual void * | getPointerToFunctionOrStub (Function *F) |
| getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. | |
| const GlobalValue * | getGlobalValueAtAddress (void *Addr) |
| getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address. | |
| void | StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty) |
| StoreValueToMemory - Stores the data in Val of type Ty at address Ptr. | |
| void | InitializeMemory (const Constant *Init, void *Addr) |
| virtual void * | getOrEmitGlobalVariable (const GlobalVariable *GV) |
| getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed. | |
| void | DisableLazyCompilation (bool Disabled=true) |
| DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile every function reachable from the argument to getPointerToFunction. | |
| bool | isCompilingLazily () const |
| void | DisableGVCompilation (bool Disabled=true) |
| DisableGVCompilation - If called, the JIT will abort if it's asked to allocate space and populate a GlobalVariable that is not internal to the module. | |
| bool | isGVCompilationDisabled () const |
| void | DisableSymbolSearching (bool Disabled=true) |
| DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym. | |
| bool | isSymbolSearchingDisabled () const |
| void | setVerifyModules (bool Verify) |
| Enable/Disable IR module verification. | |
| bool | getVerifyModules () const |
| void | InstallLazyFunctionCreator (FunctionCreator C) |
| InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. |
| (Private) Registration Interfaces | |
|---|---|
| JITSymbol | findSymbol (const std::string &Name, bool CheckFunctionsOnly) |
| uint64_t | getSymbolAddress (const std::string &Name, bool CheckFunctionsOnly) |
| static void | Register () |
| static ExecutionEngine * | createJIT (std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< LegacyJITSymbolResolver > Resolver, std::unique_ptr< TargetMachine > TM) |
| std::unique_ptr< MemoryBuffer > | emitObject (Module *M) |
| emitObject – Generate a JITed object in memory from the specified module Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module. | |
| void | notifyObjectLoaded (const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L) |
| void | notifyFreeingObject (const object::ObjectFile &Obj) |
| JITSymbol | findExistingSymbol (const std::string &Name) |
| Module * | findModuleForSymbol (const std::string &Name, bool CheckFunctionsOnly) |
| Additional Inherited Members | |
|---|---|
| Public Attributes inherited from llvm::ExecutionEngine | |
| sys::Mutex | lock |
| lock - This lock protects the ExecutionEngine and MCJIT classes. | |
| Protected Member Functions inherited from llvm::ExecutionEngine | |
| virtual char * | getMemoryForGV (const GlobalVariable *GV) |
| getMemoryforGV - Allocate memory for a global variable. | |
| std::string | getMangledName (const GlobalValue *GV) |
| getMangledName - Get mangled name. | |
| ExecutionEngine (DataLayout DL) | |
| ExecutionEngine (DataLayout DL, std::unique_ptr< Module > M) | |
| ExecutionEngine (std::unique_ptr< Module > M) | |
| void | emitGlobals () |
| EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress. | |
| void | emitGlobalVariable (const GlobalVariable *GV) |
| GenericValue | getConstantValue (const Constant *C) |
| Converts a Constant* into a GenericValue, including handling of ConstantExpr values. | |
| void | LoadValueFromMemory (GenericValue &Result, GenericValue *Ptr, Type *Ty) |
| FIXME: document. | |
| Protected Attributes inherited from llvm::ExecutionEngine | |
| SmallVector< std::unique_ptr< Module >, 1 > | Modules |
| The list of Modules that we are JIT'ing from. | |
| FunctionCreator | LazyFunctionCreator |
| LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. | |
| std::string | ErrMsg |
| Static Protected Attributes inherited from llvm::ExecutionEngine | |
| static ExecutionEngine *(* | MCJITCtor )(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< LegacyJITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM) = nullptr |
| static ExecutionEngine *(* | InterpCtor )(std::unique_ptr< Module > M, std::string *ErrorStr) =nullptr |
Definition at line 66 of file MCJIT.h.
| MCJIT::~MCJIT ( ) | override |
|---|
◆ addArchive()
addArchive - Add an Archive to the execution engine.
This method is only supported by MCJIT. MCJIT will use the archive to resolve external symbols in objects it is loading. If a symbol is found in the Archive the contained object file will be extracted (in memory) and loaded for possible execution.
Reimplemented from llvm::ExecutionEngine.
Definition at line 136 of file MCJIT.cpp.
References A().
◆ addModule()
| void MCJIT::addModule ( std::unique_ptr< Module > M) | overridevirtual |
|---|
◆ addObjectFile() [1/2]
◆ addObjectFile() [2/2]
◆ createJIT()
◆ emitObject()
◆ finalizeLoadedModules()
| void MCJIT::finalizeLoadedModules | ( | ) |
|---|
◆ finalizeModule()
| void MCJIT::finalizeModule ( Module * M) | virtual |
|---|
◆ finalizeObject()
| void MCJIT::finalizeObject ( ) | overridevirtual |
|---|
finalizeObject - ensure the module is fully processed and is usable.
It is the user-level function for completing the process of making the object usable for execution. It should be called after sections within an object have been relocated using mapSectionAddress. When this method is called the MCJIT execution engine will reapply relocations for a loaded object. Is it OK to finalize a set of modules, add modules and finalize again.
Reimplemented from llvm::ExecutionEngine.
Definition at line 257 of file MCJIT.cpp.
References finalizeLoadedModules(), generateCodeForModule(), and llvm::ExecutionEngine::lock.
◆ findExistingSymbol()
| JITSymbol MCJIT::findExistingSymbol ( const std::string & Name) | protected |
|---|
◆ FindFunctionNamed()
FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
This is very slow operation and shouldn't be used for general code.
Reimplemented from llvm::ExecutionEngine.
Definition at line 486 of file MCJIT.cpp.
References F.
◆ FindGlobalVariableNamed()
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name.
This is very slow operation and shouldn't be used for general code.
Reimplemented from llvm::ExecutionEngine.
Definition at line 498 of file MCJIT.cpp.
◆ findModuleForSymbol()
| Module * MCJIT::findModuleForSymbol ( const std::string & Name, bool CheckFunctionsOnly ) | protected |
|---|
◆ findSymbol()
Definition at line 336 of file MCJIT.cpp.
References A(), addObjectFile(), llvm::consumeError(), llvm::JITSymbolFlags::Exported, findExistingSymbol(), findModuleForSymbol(), generateCodeForModule(), llvm::Expected< T >::get(), llvm::ExecutionEngine::LazyFunctionCreator, llvm::ExecutionEngine::lock, llvm::report_fatal_error(), and llvm::Expected< T >::takeError().
Referenced by getSymbolAddress().
◆ generateCodeForModule()
| void MCJIT::generateCodeForModule ( Module * M) | overridevirtual |
|---|
generateCodeForModule - Run code generation for the specified module and load it into memory.
When this function has completed, all code and data for the specified module, and any module on which this module depends, will be generated and loaded into memory, but relocations will not yet have been applied and all memory will be readable and writable but not executable.
This function is primarily useful when generating code for an external target, allowing the client an opportunity to remap section addresses before relocations are applied. Clients that intend to execute code locally can use the getFunctionAddress call, which will generate code and apply final preparations all in one step.
This method has no effect for the interpreter.
Reimplemented from llvm::ExecutionEngine.
Definition at line 188 of file MCJIT.cpp.
References assert(), llvm::object::ObjectFile::createObjectFile(), emitObject(), llvm::Expected< T >::get(), llvm::ExecutionEngine::getDataLayout(), llvm::ExecutionEngine::lock, llvm::logAllUnhandledErrors(), notifyObjectLoaded(), llvm::report_fatal_error(), and llvm::Expected< T >::takeError().
Referenced by finalizeModule(), finalizeObject(), findSymbol(), and getPointerToFunction().
◆ getFunctionAddress()
| uint64_t MCJIT::getFunctionAddress ( const std::string & Name) | overridevirtual |
|---|
◆ getGlobalValueAddress()
| uint64_t MCJIT::getGlobalValueAddress ( const std::string & Name) | overridevirtual |
|---|
◆ getPointerToFunction()
| void * MCJIT::getPointerToFunction ( Function * F) | overridevirtual |
|---|
◆ getPointerToNamedFunction()
| void * MCJIT::getPointerToNamedFunction ( StringRef Name, bool AbortOnFailure = true ) | overridevirtual |
|---|
◆ getSymbolAddress()
| uint64_t MCJIT::getSymbolAddress | ( | const std::string & | Name, |
|---|---|---|---|
| bool | CheckFunctionsOnly ) |
◆ getTargetMachine()
| TargetMachine * llvm::MCJIT::getTargetMachine ( ) | inlineoverridevirtual |
|---|
◆ mapSectionAddress()
| void llvm::MCJIT::mapSectionAddress ( const void * LocalAddress, uint64_t TargetAddress ) | inlineoverridevirtual |
|---|
mapSectionAddress - map a section to its target address space value.
Map the address of a JIT section as returned from the memory manager to the address in the target process as the running code will see it. This is the address which will be used for relocation resolution.
Reimplemented from llvm::ExecutionEngine.
Definition at line 271 of file MCJIT.h.
◆ notifyFreeingObject()
◆ notifyObjectLoaded()
◆ Register()
| void llvm::MCJIT::Register ( ) | inlinestatic |
|---|
◆ RegisterJITEventListener()
◆ removeModule()
| bool MCJIT::removeModule ( Module * M) | overridevirtual |
|---|
◆ runFunction()
runFunction - Execute the specified function with the specified arguments, and return the result.
For MCJIT execution engines, clients are encouraged to use the "GetFunctionAddress" method (rather than runFunction) and cast the returned uint64_t to the desired function pointer type. However, for backwards compatibility MCJIT's implementation can execute 'main-like' function (i.e. those returning void or int, and taking either no arguments or (int, char*[])).
Implements llvm::ExecutionEngine.
Definition at line 510 of file MCJIT.cpp.
References assert(), llvm::BitWidth, llvm::cast(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::ArrayRef< T >::empty(), F, finalizeModule(), float, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), getPointerToFunction(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::report_fatal_error(), llvm::ArrayRef< T >::size(), llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.
◆ runStaticConstructorsDestructors()
| void MCJIT::runStaticConstructorsDestructors ( bool isDtors) | overridevirtual |
|---|
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.
Parameters
| isDtors | - Run the destructors instead of constructors. |
|---|
Reimplemented from llvm::ExecutionEngine.
Definition at line 452 of file MCJIT.cpp.
◆ setObjectCache()
| void MCJIT::setObjectCache ( ObjectCache * manager) | overridevirtual |
|---|
◆ setProcessAllSections()
| void llvm::MCJIT::setProcessAllSections ( bool ProcessAllSections) | inlineoverridevirtual |
|---|
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.
Passing 'true' to this method will cause RuntimeDyld to pass all sections to its RTDyldMemoryManager regardless of whether they are "required to execute" in the usual sense.
Rationale: Some MCJIT clients want to be able to inspect metadata sections (e.g. Dwarf, Stack-maps) to enable functionality or analyze performance. Passing these sections to the memory manager allows the client to make policy about the relevant sections, rather than having MCJIT do it.
Reimplemented from llvm::ExecutionEngine.
Definition at line 226 of file MCJIT.h.
◆ UnregisterJITEventListener()
The documentation for this class was generated from the following files: