LLVM
8.0.1
|
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations. More...
#include "llvm/ExecutionEngine/ExecutionEngine.h"
Public Member Functions | |
virtual | ~ExecutionEngine () |
virtual void | addModule (std::unique_ptr< Module > M) |
Add a Module to the list of modules that we can JIT from. More... | |
virtual void | addObjectFile (std::unique_ptr< object::ObjectFile > O) |
addObjectFile - Add an ObjectFile to the execution engine. More... | |
virtual void | addObjectFile (object::OwningBinary< object::ObjectFile > O) |
virtual void | addArchive (object::OwningBinary< object::Archive > A) |
addArchive - Add an Archive to the execution engine. More... | |
const DataLayout & | getDataLayout () const |
virtual bool | removeModule (Module *M) |
removeModule - Removes a Module from the list of modules, but does not free the module's memory. More... | |
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 GenericValue | runFunction (Function *F, ArrayRef< GenericValue > ArgValues)=0 |
runFunction - Execute the specified function with the specified arguments, and return the result. More... | |
virtual void * | getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true)=0 |
getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. More... | |
virtual void | mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) |
mapSectionAddress - map a section to its target address space value. More... | |
virtual void | generateCodeForModule (Module *M) |
generateCodeForModule - Run code generation for the specified module and load it into memory. More... | |
virtual void | finalizeObject () |
finalizeObject - ensure the module is fully processed and is usable. More... | |
virtual void | runStaticConstructorsDestructors (bool isDtors) |
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program. 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 * | getPointerToFunction (Function *F)=0 |
getPointerToFunction - The different EE's represent function bodies in different ways. More... | |
virtual void * | getPointerToFunctionOrStub (Function *F) |
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. More... | |
virtual uint64_t | getGlobalValueAddress (const std::string &Name) |
getGlobalValueAddress - Return the address of the specified global value. More... | |
virtual uint64_t | getFunctionAddress (const std::string &Name) |
getFunctionAddress - Return the address of the specified 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 void | setObjectCache (ObjectCache *) |
Sets the pre-compiled object cache. More... | |
virtual void | setProcessAllSections (bool ProcessAllSections) |
setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded. More... | |
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... | |
Public Attributes | |
sys::Mutex | lock |
lock - This lock protects the ExecutionEngine and MCJIT classes. More... | |
Protected Member Functions | |
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 | |
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 | |
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 |
Friends | |
class | EngineBuilder |
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations.
Definition at line 100 of file ExecutionEngine.h.
|
virtual |
Definition at line 94 of file ExecutionEngine.cpp.
References llvm::alignTo(), clearAllGlobalMappings(), llvm::DataLayout::getPreferredAlignment(), llvm::DataLayout::getTypeAllocSize(), and llvm::GlobalValue::getValueType().
|
inlineprotected |
Definition at line 496 of file ExecutionEngine.h.
References C, and getConstantValue().
|
explicitprotected |
Definition at line 89 of file ExecutionEngine.cpp.
|
explicitprotected |
Definition at line 84 of file ExecutionEngine.cpp.
|
virtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 140 of file ExecutionEngine.cpp.
References llvm_unreachable.
void ExecutionEngine::addGlobalMapping | ( | const GlobalValue * | GV, |
void * | Addr | ||
) |
addGlobalMapping - Tell the execution engine that the specified global is at the specified location.
This is used internally as functions are JIT'd and as global variables are laid out in memory. It can and should also be used by clients of the EE that want to have an LLVM global overlay existing data in memory. Values to be mapped should be named, and have external or weak linkage. Mappings are automatically removed when their GlobalValue is destroyed.
Definition at line 207 of file ExecutionEngine.cpp.
References getMangledName(), and lock.
void ExecutionEngine::addGlobalMapping | ( | StringRef | Name, |
uint64_t | Addr | ||
) |
Definition at line 212 of file ExecutionEngine.cpp.
References assert(), llvm::dbgs(), llvm::StringRef::empty(), LLVM_DEBUG, lock, and Name.
|
inlinevirtual |
Add a Module to the list of modules that we can JIT from.
Reimplemented in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 173 of file ExecutionEngine.h.
References A, llvm::RISCVFenceField::O, and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by llvm::EngineBuilder::create().
|
virtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 131 of file ExecutionEngine.cpp.
References llvm_unreachable.
|
virtual |
Reimplemented in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 136 of file ExecutionEngine.cpp.
References llvm_unreachable.
void ExecutionEngine::clearAllGlobalMappings | ( | ) |
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals.
Definition at line 231 of file ExecutionEngine.cpp.
References lock.
Referenced by ~ExecutionEngine().
void ExecutionEngine::clearGlobalMappingsFromModule | ( | Module * | M | ) |
clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT.
Definition at line 238 of file ExecutionEngine.cpp.
References getMangledName(), llvm::Module::global_objects(), and lock.
Referenced by removeModule().
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.
Definition at line 460 of file ExecutionEngine.h.
DisableLazyCompilation - When lazy compilation is off (the default), the JIT will eagerly compile every function reachable from the argument to getPointerToFunction.
If lazy compilation is turned on, the JIT will only compile the one function and emit stubs to compile the rest when they're first called. If lazy compilation is turned off again while some lazy stubs are still around, and one of those stubs is called, the program will abort.
In order to safely compile lazily in a threaded program, the user must ensure that 1) only one thread at a time can call any particular lazy stub, and 2) any thread modifying LLVM IR must hold the JIT's lock (ExecutionEngine::lock) or otherwise ensure that no other thread calls a lazy stub. See http://llvm.org/PR5184 for details.
Definition at line 450 of file ExecutionEngine.h.
DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym.
A client can still use InstallLazyFunctionCreator to resolve symbols in a custom way.
Definition at line 470 of file ExecutionEngine.h.
|
protected |
EmitGlobals - Emit all of the global variables to memory, storing their addresses into GlobalAddress.
This must make sure to copy the contents of their initializers into the memory.
Definition at line 1242 of file ExecutionEngine.cpp.
References assert(), llvm::Value::getName(), llvm::GlobalValue::getType(), llvm::Module::globals(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::report_fatal_error(), and llvm::sys::DynamicLibrary::SearchForAddressOfSymbol().
Referenced by llvm::Interpreter::Interpreter().
|
protected |
Definition at line 1342 of file ExecutionEngine.cpp.
References llvm::GlobalVariable::getInitializer(), llvm::GlobalValue::getValueType(), and llvm::GlobalValue::isThreadLocal().
|
inlinevirtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 278 of file ExecutionEngine.h.
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 in llvm::MCJIT.
Definition at line 157 of file ExecutionEngine.cpp.
References F(), llvm::GlobalValue::isDeclaration(), and Modules.
|
virtual |
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 in llvm::MCJIT.
Definition at line 166 of file ExecutionEngine.cpp.
References llvm::GlobalValue::isDeclaration(), and Modules.
|
inlinevirtual |
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 interpeter.
Reimplemented in llvm::MCJIT.
Definition at line 269 of file ExecutionEngine.h.
uint64_t ExecutionEngine::getAddressToGlobalIfAvailable | ( | StringRef | S | ) |
getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.
Definition at line 278 of file ExecutionEngine.cpp.
References llvm::Address, I, and lock.
Referenced by getPointerToGlobalIfAvailable().
|
protected |
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
Definition at line 595 of file ExecutionEngine.cpp.
References llvm::MCID::Add, llvm::APFloat::add(), llvm::GenericValue::AggregateVal, llvm::lltok::APFloat, assert(), llvm::APFloat::bitcastToAPInt(), llvm::APInt::bitsToDouble(), llvm::APInt::bitsToFloat(), C, llvm::APFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), llvm::APFloat::divide(), llvm::APInt::doubleToBits(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::dyn_cast(), F(), llvm::APInt::floatToBits(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::UndefValue::get(), getBitWidth(), llvm::APInt::getBitWidth(), getConstantValue(), llvm::ConstantDataSequential::getElementAsDouble(), llvm::ConstantDataSequential::getElementAsFloat(), llvm::ConstantDataSequential::getElementAsInteger(), llvm::SequentialType::getElementType(), llvm::ConstantDataSequential::getElementType(), llvm::SequentialType::getNumElements(), llvm::ConstantDataSequential::getNumElements(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::APFloat::getZero(), llvm::APInt::getZExtValue(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::Type::isAggregateType(), llvm::Type::isDoubleTy(), llvm::Type::isFloatingPointTy(), llvm::Type::isFloatTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isX86_FP80Ty(), llvm_unreachable, llvm::makeMutableArrayRef(), llvm::APFloat::mod(), llvm::APFloat::multiply(), llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::report_fatal_error(), llvm::APFloatBase::rmNearestTiesToEven, llvm::APFloatBase::rmTowardZero, llvm::APIntOps::RoundDoubleToAPInt(), llvm::APIntOps::RoundFloatToAPInt(), llvm::APInt::roundToDouble(), llvm::APInt::sdiv(), llvm::APInt::sext(), llvm::APInt::signedRoundToDouble(), llvm::APInt::srem(), llvm::raw_svector_ostream::str(), llvm::Type::StructTyID, llvm::APFloat::subtract(), llvm::APInt::trunc(), llvm::APInt::udiv(), llvm::APInt::urem(), llvm::Type::VectorTyID, llvm::Type::X86_FP80TyID, llvm::APFloatBase::x87DoubleExtended(), llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().
Referenced by llvm::Interpreter::visitInsertValueInst().
|
inline |
Definition at line 200 of file ExecutionEngine.h.
Referenced by llvm::orc::OrcMCJITReplacement::addModule(), llvm::Interpreter::callExternalFunction(), getGlobalValueAtAddress(), getMangledName(), getMemoryForGV(), llvm::Interpreter::Interpreter(), isTargetNullPtr(), lle_X_sprintf(), llvm::orc::OrcMCJITReplacement::setProcessAllSections(), llvm::Interpreter::visitAllocaInst(), and llvm::Interpreter::visitAShr().
|
inlinevirtual |
getFunctionAddress - Return the address of the specified function.
This may involve code generation.
Reimplemented in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 376 of file ExecutionEngine.h.
|
inlinevirtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 368 of file ExecutionEngine.h.
const GlobalValue * ExecutionEngine::getGlobalValueAtAddress | ( | void * | Addr | ) |
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.
Definition at line 301 of file ExecutionEngine.cpp.
References llvm::sys::path::begin(), C, llvm::copy(), llvm::dbgs(), E, llvm::sys::path::end(), getDataLayout(), llvm::Type::getInt8PtrTy(), llvm::DataLayout::getPointerSize(), I, LLVM_DEBUG, lock, Modules, Name, llvm::PTOGV(), Size, and StoreValueToMemory().
|
protected |
getMangledName - Get mangled name.
Definition at line 192 of file ExecutionEngine.cpp.
References assert(), getDataLayout(), llvm::Module::getDataLayout(), llvm::Value::getName(), llvm::Mangler::getNameWithPrefix(), llvm::GlobalValue::getParent(), llvm::Value::hasName(), llvm::DataLayout::isDefault(), lock, and llvm::SmallString< InternalLen >::str().
Referenced by addGlobalMapping(), clearGlobalMappingsFromModule(), getPointerToGlobalIfAvailable(), and updateGlobalMapping().
|
protectedvirtual |
getMemoryforGV - Allocate memory for a global variable.
Definition at line 127 of file ExecutionEngine.cpp.
References getDataLayout().
|
inlinevirtual |
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed.
This is used by the Emitter.
This function is deprecated for the MCJIT execution engine. Use getGlobalValueAddress instead.
Definition at line 402 of file ExecutionEngine.h.
|
pure virtual |
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.
Implemented in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
|
inlinevirtual |
getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function.
If not, compile it, or use a stub to implement lazy compilation if available. See getPointerToFunction for the requirements on destroying F.
This function is deprecated for the MCJIT execution engine. Use getFunctionAddress instead.
Definition at line 359 of file ExecutionEngine.h.
void * ExecutionEngine::getPointerToGlobal | ( | const GlobalValue * | GV | ) |
getPointerToGlobal - This returns the address of the specified global value.
This may involve code generation if it's a function.
This function is deprecated for the MCJIT execution engine. Use getGlobalValueAddress instead.
Definition at line 575 of file ExecutionEngine.cpp.
References F(), llvm_unreachable, and P.
Referenced by llvm::Interpreter::visitInsertValueInst().
void * ExecutionEngine::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.
Definition at line 289 of file ExecutionEngine.cpp.
References llvm::Address, getAddressToGlobalIfAvailable(), and lock.
Referenced by llvm::Interpreter::callExternalFunction(), and getPointerToGlobalIfAvailable().
void * ExecutionEngine::getPointerToGlobalIfAvailable | ( | const GlobalValue * | GV | ) |
Definition at line 296 of file ExecutionEngine.cpp.
References getMangledName(), getPointerToGlobalIfAvailable(), and lock.
|
pure virtual |
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.
Implemented in llvm::orc::OrcMCJITReplacement, llvm::MCJIT, and llvm::Interpreter.
|
inlinevirtual |
Return the target machine (if available).
Reimplemented in llvm::MCJIT.
Definition at line 435 of file ExecutionEngine.h.
|
inline |
Definition at line 484 of file ExecutionEngine.h.
Definition at line 1186 of file ExecutionEngine.cpp.
References llvm::HexagonISD::CP, llvm::Data, llvm::StringRef::data(), llvm::dbgs(), llvm::Value::dump(), getConstantValue(), llvm::StructLayout::getElementOffset(), llvm::Value::getType(), llvm::Type::isFirstClassType(), LLVM_DEBUG, llvm_unreachable, llvm::Intrinsic::memcpy, llvm::Intrinsic::memset, and llvm::StringRef::size().
|
inline |
InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it.
If it returns null, the JIT will abort.
Definition at line 491 of file ExecutionEngine.h.
|
inline |
Definition at line 453 of file ExecutionEngine.h.
|
inline |
Definition at line 463 of file ExecutionEngine.h.
|
inline |
Definition at line 473 of file ExecutionEngine.h.
|
protected |
FIXME: document.
Definition at line 1125 of file ExecutionEngine.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, getBitWidth(), llvm::Type::getTypeID(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, LoadIntFromMemory(), llvm::Intrinsic::memcpy, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::report_fatal_error(), llvm::raw_svector_ostream::str(), llvm::Type::VectorTyID, and llvm::Type::X86_FP80TyID.
Referenced by llvm::Interpreter::visitLoadInst().
|
inlinevirtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 248 of file ExecutionEngine.h.
References llvm_unreachable.
|
inlinevirtual |
Registers a listener to be called back on various events within the JIT.
See JITEventListener.h for more details. Does not take ownership of the argument. The argument may be NULL, in which case these functions do nothing.
Reimplemented in llvm::MCJIT.
Definition at line 410 of file ExecutionEngine.h.
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 144 of file ExecutionEngine.cpp.
References clearGlobalMappingsFromModule(), E, I, and Modules.
|
pure virtual |
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*[])).
Implemented in llvm::orc::OrcMCJITReplacement, llvm::MCJIT, and llvm::Interpreter.
Referenced by runFunctionAsMain(), and runStaticConstructorsDestructors().
int ExecutionEngine::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.
Definition at line 427 of file ExecutionEngine.cpp.
References assert(), llvm::Function::getContext(), llvm::Function::getFunctionType(), llvm::Type::getInt8PtrTy(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::APInt::getZExtValue(), llvm::GVTOP(), llvm::GenericValue::IntVal, llvm::Type::isIntegerTy(), isTargetNullPtr(), llvm::Type::isVoidTy(), llvm::PTOGV(), llvm::report_fatal_error(), and runFunction().
|
virtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 410 of file ExecutionEngine.cpp.
References Modules.
Referenced by llvm::MCJIT::getPointerToFunction().
This method is used to execute all of the static constructors or destructors for a particular module.
isDtors | - Run the destructors instead of constructors. |
Definition at line 371 of file ExecutionEngine.cpp.
References llvm::dyn_cast(), F(), llvm::GlobalVariable::getInitializer(), llvm::Module::getNamedGlobal(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::isDeclaration(), llvm::Constant::isNullValue(), Name, llvm::None, and runFunction().
|
inlinevirtual |
Sets the pre-compiled object cache.
The ownership of the ObjectCache is not changed. Supported by MCJIT but not the interpreter.
Reimplemented in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 415 of file ExecutionEngine.h.
References llvm_unreachable.
|
inlinevirtual |
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 in llvm::orc::OrcMCJITReplacement, and llvm::MCJIT.
Definition at line 430 of file ExecutionEngine.h.
References llvm_unreachable.
|
inline |
Enable/Disable IR module verification.
Note: Module verification is enabled by default in Debug builds, and disabled by default in Release. Use this method to override the default.
Definition at line 481 of file ExecutionEngine.h.
References Verify.
Referenced by llvm::EngineBuilder::create().
void ExecutionEngine::StoreValueToMemory | ( | const GenericValue & | Val, |
GenericValue * | Ptr, | ||
Type * | Ty | ||
) |
StoreValueToMemory - Stores the data in Val of type Ty at address Ptr.
Ptr is the address of the memory at which to store Val, cast to GenericValue *. It is not a pointer to a GenericValue containing the address at which to store Val.
Definition at line 1049 of file ExecutionEngine.cpp.
References llvm::GenericValue::AggregateVal, llvm::dbgs(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::APInt::getRawData(), llvm::Type::getTypeID(), if(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::sys::IsLittleEndianHost, llvm::Intrinsic::memcpy, llvm::Intrinsic::memset, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::reverse(), StoreIntToMemory(), llvm::Type::VectorTyID, and llvm::Type::X86_FP80TyID.
Referenced by getGlobalValueAtAddress(), and llvm::Interpreter::visitStoreInst().
|
inlinevirtual |
Reimplemented in llvm::MCJIT.
Definition at line 411 of file ExecutionEngine.h.
uint64_t ExecutionEngine::updateGlobalMapping | ( | const GlobalValue * | GV, |
void * | Addr | ||
) |
updateGlobalMapping - Replace an existing mapping for GV with a new address.
This updates both maps as required. If "Addr" is null, the entry for the global is removed from the mappings. This returns the old value of the pointer, or null if it was not in the map.
Definition at line 245 of file ExecutionEngine.cpp.
References getMangledName(), and lock.
uint64_t ExecutionEngine::updateGlobalMapping | ( | StringRef | Name, |
uint64_t | Addr | ||
) |
Definition at line 251 of file ExecutionEngine.cpp.
References assert(), llvm::StringRef::empty(), llvm::StringMap< ValueTy, AllocatorTy >::erase(), lock, and Name.
|
friend |
Definition at line 129 of file ExecutionEngine.h.
|
staticprotected |
Definition at line 150 of file ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create().
|
protected |
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it.
If this returns null, the JIT will abort.
Definition at line 156 of file ExecutionEngine.h.
sys::Mutex llvm::ExecutionEngine::lock |
lock - This lock protects the ExecutionEngine and MCJIT classes.
It must be held while changing the internal state of any of those classes.
Definition at line 164 of file ExecutionEngine.h.
Referenced by addGlobalMapping(), clearAllGlobalMappings(), clearGlobalMappingsFromModule(), getAddressToGlobalIfAvailable(), getGlobalValueAtAddress(), getMangledName(), getPointerToGlobalIfAvailable(), and updateGlobalMapping().
|
staticprotected |
Definition at line 139 of file ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create().
|
protected |
The list of Modules that we are JIT'ing from.
We use a SmallVector to optimize for the case where there is only one module.
Definition at line 134 of file ExecutionEngine.h.
Referenced by FindFunctionNamed(), FindGlobalVariableNamed(), getGlobalValueAtAddress(), llvm::orc::OrcMCJITReplacement::OrcMCJITReplacement(), removeModule(), llvm::orc::OrcMCJITReplacement::removeModule(), and runStaticConstructorsDestructors().
|
staticprotected |
Definition at line 145 of file ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create(), and llvm::orc::OrcMCJITReplacement::Register().