LLVM
8.0.1
|
#include "ExecutionEngine/Orc/OrcMCJITReplacement.h"
Public Member Functions | |
OrcMCJITReplacement (std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< LegacyJITSymbolResolver > ClientResolver, std::unique_ptr< TargetMachine > TM) | |
void | addModule (std::unique_ptr< Module > M) override |
Add a Module to the list of modules that we can JIT from. More... | |
void | addObjectFile (std::unique_ptr< object::ObjectFile > O) override |
addObjectFile - Add an ObjectFile to the execution engine. More... | |
void | addObjectFile (object::OwningBinary< object::ObjectFile > O) override |
void | addArchive (object::OwningBinary< object::Archive > A) override |
addArchive - Add an Archive to the execution engine. More... | |
bool | removeModule (Module *M) override |
removeModule - Removes a Module from the list of modules, but does not free the module's memory. More... | |
uint64_t | getSymbolAddress (StringRef Name) |
JITSymbol | findSymbol (StringRef Name) |
void | finalizeObject () override |
finalizeObject - ensure the module is fully processed and is usable. More... | |
void | mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) override |
mapSectionAddress - map a section to its target address space value. More... | |
uint64_t | getGlobalValueAddress (const std::string &Name) override |
getGlobalValueAddress - Return the address of the specified global value. More... | |
uint64_t | getFunctionAddress (const std::string &Name) override |
getFunctionAddress - Return the address of the specified function. More... | |
void * | getPointerToFunction (Function *F) override |
getPointerToFunction - The different EE's represent function bodies in different ways. More... | |
void * | getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override |
getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. More... | |
GenericValue | runFunction (Function *F, ArrayRef< GenericValue > ArgValues) override |
runFunction - Execute the specified function with the specified arguments, and return the result. More... | |
void | setObjectCache (ObjectCache *NewCache) override |
Sets the pre-compiled object cache. More... | |
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. More... | |
void | runStaticConstructorsDestructors (bool isDtors) override |
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program. More... | |
Public Member Functions inherited from llvm::ExecutionEngine | |
virtual | ~ExecutionEngine () |
const DataLayout & | getDataLayout () const |
virtual Function * | FindFunctionNamed (StringRef FnName) |
FindFunctionNamed - Search all of the active modules to find the function that defines FnName. More... | |
virtual GlobalVariable * | FindGlobalVariableNamed (StringRef Name, bool AllowInternal=false) |
FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name. More... | |
virtual void | generateCodeForModule (Module *M) |
generateCodeForModule - Run code generation for the specified module and load it into memory. More... | |
void | runStaticConstructorsDestructors (Module &module, bool isDtors) |
This method is used to execute all of the static constructors or destructors for a particular module. More... | |
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. More... | |
void | addGlobalMapping (const GlobalValue *GV, void *Addr) |
addGlobalMapping - Tell the execution engine that the specified global is at the specified location. More... | |
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. More... | |
void | clearGlobalMappingsFromModule (Module *M) |
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT. More... | |
uint64_t | updateGlobalMapping (const GlobalValue *GV, void *Addr) |
updateGlobalMapping - Replace an existing mapping for GV with a new address. More... | |
uint64_t | updateGlobalMapping (StringRef Name, uint64_t Addr) |
uint64_t | getAddressToGlobalIfAvailable (StringRef S) |
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol. More... | |
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. More... | |
void * | getPointerToGlobalIfAvailable (const GlobalValue *GV) |
void * | getPointerToGlobal (const GlobalValue *GV) |
getPointerToGlobal - This returns the address of the specified global value. More... | |
virtual void * | getPointerToFunctionOrStub (Function *F) |
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. More... | |
const GlobalValue * | getGlobalValueAtAddress (void *Addr) |
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address. More... | |
void | StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty) |
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr. More... | |
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. More... | |
virtual void | RegisterJITEventListener (JITEventListener *) |
Registers a listener to be called back on various events within the JIT. More... | |
virtual void | UnregisterJITEventListener (JITEventListener *) |
virtual TargetMachine * | getTargetMachine () |
Return the target machine (if available). More... | |
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. More... | |
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. More... | |
bool | isGVCompilationDisabled () const |
void | DisableSymbolSearching (bool Disabled=true) |
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym. More... | |
bool | isSymbolSearchingDisabled () const |
void | setVerifyModules (bool Verify) |
Enable/Disable IR module verification. More... | |
bool | getVerifyModules () const |
void | InstallLazyFunctionCreator (FunctionCreator C) |
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. More... | |
Static Public Member Functions | |
static void | Register () |
Additional Inherited Members | |
Public Attributes inherited from llvm::ExecutionEngine | |
sys::Mutex | lock |
lock - This lock protects the ExecutionEngine and MCJIT classes. More... | |
Protected Member Functions inherited from llvm::ExecutionEngine | |
virtual char * | getMemoryForGV (const GlobalVariable *GV) |
getMemoryforGV - Allocate memory for a global variable. More... | |
std::string | getMangledName (const GlobalValue *GV) |
getMangledName - Get mangled name. More... | |
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. More... | |
void | EmitGlobalVariable (const GlobalVariable *GV) |
GenericValue | getConstantValue (const Constant *C) |
Converts a Constant* into a GenericValue, including handling of ConstantExpr values. More... | |
void | LoadValueFromMemory (GenericValue &Result, GenericValue *Ptr, Type *Ty) |
FIXME: document. More... | |
Protected Attributes inherited from llvm::ExecutionEngine | |
SmallVector< std::unique_ptr< Module >, 1 > | Modules |
The list of Modules that we are JIT'ing from. More... | |
FunctionCreator | LazyFunctionCreator |
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. More... | |
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 *(* | OrcMCJITReplacementCtor )(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 57 of file OrcMCJITReplacement.h.
|
inline |
Definition at line 236 of file OrcMCJITReplacement.h.
References llvm::ExecutionEngine::Modules.
|
inlineoverridevirtual |
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 314 of file OrcMCJITReplacement.h.
|
inlineoverridevirtual |
Add a Module to the list of modules that we can JIT from.
Reimplemented from llvm::ExecutionEngine.
Definition at line 262 of file OrcMCJITReplacement.h.
References assert(), llvm::cantFail(), llvm::dbgs(), llvm::GlobalValue::ExternalLinkage, llvm::orc::getConstructors(), llvm::ExecutionEngine::getDataLayout(), llvm::orc::getDestructors(), and llvm::GlobalValue::HiddenVisibility.
|
inlineoverridevirtual |
addObjectFile - Add an ObjectFile to the execution engine.
This method is only supported by MCJIT. MCJIT will immediately load the object into memory and adds its symbols to the list used to resolve external symbols while preparing other objects for execution.
Objects added using this function will not be made executable until needed by another object.
MCJIT will take ownership of the ObjectFile.
Reimplemented from llvm::ExecutionEngine.
Definition at line 302 of file OrcMCJITReplacement.h.
References llvm::cantFail(), and llvm::MemoryBuffer::getMemBufferCopy().
|
inlineoverridevirtual |
Reimplemented from llvm::ExecutionEngine.
Definition at line 307 of file OrcMCJITReplacement.h.
References llvm::cantFail(), and llvm::object::OwningBinary< T >::takeBinary().
|
inlineoverridevirtual |
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. This method has no effect for the interpeter.
Reimplemented from llvm::ExecutionEngine.
Definition at line 337 of file OrcMCJITReplacement.h.
Definition at line 333 of file OrcMCJITReplacement.h.
Referenced by getSymbolAddress().
|
inlineoverridevirtual |
getFunctionAddress - Return the address of the specified function.
This may involve code generation.
Reimplemented from llvm::ExecutionEngine.
Definition at line 353 of file OrcMCJITReplacement.h.
References getSymbolAddress().
|
inlineoverridevirtual |
getGlobalValueAddress - Return the address of the specified global value.
This may involve code generation.
This function should not be called with the interpreter engine.
Reimplemented from llvm::ExecutionEngine.
Definition at line 349 of file OrcMCJITReplacement.h.
References getSymbolAddress().
|
inlineoverridevirtual |
getPointerToFunction - The different EE's represent function bodies in different ways.
They should each implement this to say what a function pointer should look like. When F is destroyed, the ExecutionEngine will remove its global mapping and free any machine code. Be sure no threads are running inside F when that happens.
This function is deprecated for the MCJIT execution engine. Use getFunctionAddress instead.
Implements llvm::ExecutionEngine.
Definition at line 357 of file OrcMCJITReplacement.h.
References llvm::Value::getName(), and getSymbolAddress().
|
inlineoverridevirtual |
getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call.
As such it is only useful for resolving library symbols, not code generated symbols.
If AbortOnFailure is false and no function with the given name is found, this function silently returns a null pointer. Otherwise, it prints a message to stderr and aborts.
This function is deprecated for the MCJIT execution engine.
Implements llvm::ExecutionEngine.
Definition at line 362 of file OrcMCJITReplacement.h.
References F(), getSymbolAddress(), llvm_unreachable, and runFunction().
|
inline |
Definition at line 329 of file OrcMCJITReplacement.h.
References llvm::cantFail(), and findSymbol().
Referenced by getFunctionAddress(), getGlobalValueAddress(), getPointerToFunction(), and getPointerToNamedFunction().
|
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 342 of file OrcMCJITReplacement.h.
References P.
|
inlinestatic |
Definition at line 258 of file OrcMCJITReplacement.h.
References llvm::ExecutionEngine::OrcMCJITReplacementCtor.
removeModule - Removes a Module from the list of modules, but does not free the module's memory.
Returns true if M is found, in which case the caller assumes responsibility for deleting the module.
Reimplemented from llvm::ExecutionEngine.
Definition at line 318 of file OrcMCJITReplacement.h.
References E, I, and llvm::ExecutionEngine::Modules.
|
overridevirtual |
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 27 of file OrcMCJITReplacement.cpp.
References assert(), DoubleTyID, llvm::GenericValue::DoubleVal, llvm::ArrayRef< T >::empty(), FloatTyID, llvm::GenericValue::FloatVal, getBitWidth(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::GenericValue::IntVal, llvm::tgtok::IntVal, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::PTOGV(), and llvm::ArrayRef< T >::size().
Referenced by getPointerToNamedFunction().
|
overridevirtual |
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.
isDtors | - Run the destructors instead of constructors. |
Reimplemented from llvm::ExecutionEngine.
Definition at line 127 of file OrcMCJITReplacement.cpp.
References llvm::cantFail(), and llvm::orc::LegacyCtorDtorRunner< JITLayerT >::runViaLayer().
Referenced by setProcessAllSections().
|
inlineoverridevirtual |
Sets the pre-compiled object cache.
The ownership of the ObjectCache is not changed. Supported by MCJIT but not the interpreter.
Reimplemented from llvm::ExecutionEngine.
Definition at line 373 of file OrcMCJITReplacement.h.
|
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 377 of file OrcMCJITReplacement.h.
References llvm::cantFail(), llvm::consumeError(), llvm::object::Archive::findSym(), llvm::Expected< T >::get(), llvm::ExecutionEngine::getDataLayout(), llvm::MemoryBuffer::getMemBufferCopy(), Info, Name, llvm::X86II::OB, llvm::report_fatal_error(), runStaticConstructorsDestructors(), and llvm::Expected< T >::takeError().