LLVM API Documentation
Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations. More...
#include <ExecutionEngine.h>


Public Member Functions | |
| virtual | ~ExecutionEngine () |
| virtual void | addModule (Module *M) |
| const DataLayout * | getDataLayout () const |
| virtual bool | removeModule (Module *M) |
| Function * | FindFunctionNamed (const char *FnName) |
| virtual GenericValue | runFunction (Function *F, const std::vector< GenericValue > &ArgValues)=0 |
| virtual void * | getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true)=0 |
| virtual void | mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) |
| virtual void | finalizeObject () |
| void | runStaticConstructorsDestructors (bool isDtors) |
| void | runStaticConstructorsDestructors (Module *module, bool isDtors) |
| int | runFunctionAsMain (Function *Fn, const std::vector< std::string > &argv, const char *const *envp) |
| void | addGlobalMapping (const GlobalValue *GV, void *Addr) |
| void | clearAllGlobalMappings () |
| void | clearGlobalMappingsFromModule (Module *M) |
| void * | updateGlobalMapping (const GlobalValue *GV, void *Addr) |
| void * | getPointerToGlobalIfAvailable (const GlobalValue *GV) |
| void * | getPointerToGlobal (const GlobalValue *GV) |
| virtual void * | getPointerToFunction (Function *F)=0 |
| virtual void * | getPointerToBasicBlock (BasicBlock *BB)=0 |
| virtual void * | getPointerToFunctionOrStub (Function *F) |
| virtual void | runJITOnFunction (Function *, MachineCodeInfo *=0) |
| const GlobalValue * | getGlobalValueAtAddress (void *Addr) |
| void | StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty) |
| void | InitializeMemory (const Constant *Init, void *Addr) |
| virtual void * | recompileAndRelinkFunction (Function *F)=0 |
| virtual void | freeMachineCodeForFunction (Function *F)=0 |
| virtual void * | getOrEmitGlobalVariable (const GlobalVariable *GV) |
| virtual void | RegisterJITEventListener (JITEventListener *) |
| virtual void | UnregisterJITEventListener (JITEventListener *) |
| virtual void | setObjectCache (ObjectCache *) |
| void | DisableLazyCompilation (bool Disabled=true) |
| bool | isCompilingLazily () const |
| bool | isLazyCompilationDisabled () const |
| void | DisableGVCompilation (bool Disabled=true) |
| bool | isGVCompilationDisabled () const |
| void | DisableSymbolSearching (bool Disabled=true) |
| bool | isSymbolSearchingDisabled () const |
| void | InstallLazyFunctionCreator (void *(*P)(const std::string &)) |
| void | InstallExceptionTableRegister (EERegisterFn F) |
| void | InstallExceptionTableDeregister (EERegisterFn F) |
| void | RegisterTable (const Function *fn, void *res) |
| void | DeregisterTable (const Function *Fn) |
| void | DeregisterAllTables () |
Static Public Member Functions | |
| static ExecutionEngine * | create (Module *M, bool ForceInterpreter=false, std::string *ErrorStr=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true) |
| static ExecutionEngine * | createJIT (Module *M, std::string *ErrorStr=0, JITMemoryManager *JMM=0, CodeGenOpt::Level OptLevel=CodeGenOpt::Default, bool GVsWithCode=true, Reloc::Model RM=Reloc::Default, CodeModel::Model CMM=CodeModel::JITDefault) |
Public Attributes | |
| sys::Mutex | lock |
Protected Types | |
| typedef void(* | EERegisterFn )(void *) |
Protected Member Functions | |
| void | setDataLayout (const DataLayout *td) |
| virtual char * | getMemoryForGV (const GlobalVariable *GV) |
| getMemoryforGV - Allocate memory for a global variable. | |
| ExecutionEngine (Module *M) | |
| void | emitGlobals () |
| 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) |
Protected Attributes | |
| SmallVector< Module *, 1 > | Modules |
| void *(* | LazyFunctionCreator )(const std::string &) |
| EERegisterFn | ExceptionTableRegister |
| EERegisterFn | ExceptionTableDeregister |
| DenseMap< const Function *, void * > | AllExceptionTables |
| This maps functions to their exception tables frames. | |
Static Protected Attributes | |
| static ExecutionEngine *(* | JITCtor )(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM) |
| static ExecutionEngine *(* | MCJITCtor )(Module *M, std::string *ErrorStr, RTDyldMemoryManager *MCJMM, bool GVsWithCode, TargetMachine *TM) |
| static ExecutionEngine *(* | InterpCtor )(Module *M, std::string *ErrorStr) |
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 101 of file ExecutionEngine/ExecutionEngine.h.
typedef void(* llvm::ExecutionEngine::EERegisterFn)(void *) [protected] |
ExceptionTableRegister - If Exception Handling is set, the JIT will register dwarf tables with this function.
Definition at line 158 of file ExecutionEngine/ExecutionEngine.h.
| ExecutionEngine::~ExecutionEngine | ( | ) | [virtual] |
Definition at line 69 of file ExecutionEngine.cpp.
References clearAllGlobalMappings(), Modules, and llvm::SmallVectorTemplateCommon< T, typename >::size().
| ExecutionEngine::ExecutionEngine | ( | Module * | M | ) | [explicit, protected] |
Definition at line 57 of file ExecutionEngine.cpp.
References Modules, and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().
| 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. Mappings are automatically removed when their GlobalValue is destroyed.
Definition at line 160 of file ExecutionEngine.cpp.
References llvm::dbgs(), DEBUG, llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), llvm::Value::getName(), and lock.
Referenced by emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::MCJIT::getPointerToFunction(), llvm::JIT::getPointerToFunction(), and llvm::JIT::recompileAndRelinkFunction().
| virtual void llvm::ExecutionEngine::addModule | ( | Module * | M | ) | [inline, virtual] |
addModule - Add a Module to the list of modules that we can JIT from. Note that this takes ownership of the Module: when the ExecutionEngine is destroyed, it destroys the Module as well.
Reimplemented in llvm::JIT.
Definition at line 213 of file ExecutionEngine/ExecutionEngine.h.
References Modules, and llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().
| void ExecutionEngine::clearAllGlobalMappings | ( | ) |
clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals.
Definition at line 178 of file ExecutionEngine.cpp.
References llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), and 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 185 of file ExecutionEngine.cpp.
References llvm::Module::begin(), llvm::Module::end(), llvm::A64CC::GE, llvm::Module::global_begin(), llvm::Module::global_end(), lock, and llvm::ExecutionEngineState::RemoveMapping().
Referenced by removeModule().
| ExecutionEngine * ExecutionEngine::create | ( | Module * | M, |
| bool | ForceInterpreter = false, |
||
| std::string * | ErrorStr = 0, |
||
| CodeGenOpt::Level | OptLevel = CodeGenOpt::Default, |
||
| bool | GVsWithCode = true |
||
| ) | [static] |
create - This is the factory method for creating an execution engine which is appropriate for the current machine. This takes ownership of the module.
| GVsWithCode | - Allocating globals with code breaks freeMachineCodeForFunction and is probably unsafe and bad for performance. However, we have clients who depend on this behavior, so we must support it. Eventually, when we're willing to break some backwards compatibility, this flag should be flipped to false, so that by default freeMachineCodeForFunction works. |
Definition at line 401 of file ExecutionEngine.cpp.
References llvm::EngineBuilder::create(), EngineBuilder, llvm::EngineKind::Interpreter, and llvm::EngineKind::JIT.
| ExecutionEngine * ExecutionEngine::createJIT | ( | Module * | M, |
| std::string * | ErrorStr = 0, |
||
| JITMemoryManager * | JMM = 0, |
||
| CodeGenOpt::Level | OL = CodeGenOpt::Default, |
||
| bool | GVsWithCode = true, |
||
| Reloc::Model | RM = Reloc::Default, |
||
| CodeModel::Model | CMM = CodeModel::JITDefault |
||
| ) | [static] |
createJIT - This is the factory method for creating a JIT for the current machine, it does not fall back to the interpreter. This takes ownership of the Module and JITMemoryManager if successful.
Clients should make sure to initialize targets prior to calling this function.
createJIT - This is the factory method for creating a JIT for the current machine, it does not fall back to the interpreter. This takes ownership of the module.
Definition at line 420 of file ExecutionEngine.cpp.
References llvm::EngineKind::JIT, JITCtor, llvm::EngineBuilder::selectTarget(), llvm::EngineBuilder::setAllocateGVsWithCode(), llvm::EngineBuilder::setCodeModel(), llvm::EngineBuilder::setEngineKind(), llvm::EngineBuilder::setErrorStr(), llvm::EngineBuilder::setJITMemoryManager(), llvm::EngineBuilder::setOptLevel(), and llvm::EngineBuilder::setRelocationModel().
| void ExecutionEngine::DeregisterAllTables | ( | ) |
DeregisterAllTables - Deregisters all previously registered pointers to an exception tables. It uses the ExceptionTableoDeregister function.
Definition at line 75 of file ExecutionEngine.cpp.
References AllExceptionTables, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), and ExceptionTableDeregister.
Referenced by llvm::JIT::~JIT().
| void llvm::ExecutionEngine::DeregisterTable | ( | const Function * | Fn | ) | [inline] |
DeregisterTable - Deregisters the exception frame previously registered for the given function.
Definition at line 458 of file ExecutionEngine/ExecutionEngine.h.
References AllExceptionTables, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::erase(), ExceptionTableDeregister, and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find().
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 414 of file ExecutionEngine/ExecutionEngine.h.
References llvm::Disabled.
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 399 of file ExecutionEngine/ExecutionEngine.h.
References llvm::Disabled.
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 424 of file ExecutionEngine/ExecutionEngine.h.
References llvm::Disabled.
| void ExecutionEngine::emitGlobals | ( | ) | [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 1174 of file ExecutionEngine.cpp.
References addGlobalMapping(), EmitGlobalVariable(), getMemoryForGV(), llvm::Value::getName(), getPointerToGlobalIfAvailable(), llvm::GlobalValue::getType(), llvm::Module::global_begin(), llvm::Module::global_end(), llvm::GlobalValue::hasAppendingLinkage(), llvm::GlobalValue::hasDLLExportLinkage(), llvm::GlobalValue::hasDLLImportLinkage(), llvm::GlobalValue::hasExternalLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::hasLocalLinkage(), llvm::Value::hasName(), I, llvm::GlobalValue::isDeclaration(), Modules, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::report_fatal_error(), llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(), and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by llvm::Interpreter::Interpreter().
| void ExecutionEngine::EmitGlobalVariable | ( | const GlobalVariable * | GV | ) | [protected] |
Definition at line 1280 of file ExecutionEngine.cpp.
References addGlobalMapping(), getDataLayout(), llvm::SequentialType::getElementType(), llvm::GlobalVariable::getInitializer(), getMemoryForGV(), getPointerToGlobalIfAvailable(), llvm::GlobalValue::getType(), llvm::DataLayout::getTypeAllocSize(), InitializeMemory(), and llvm::GlobalVariable::isThreadLocal().
Referenced by emitGlobals(), llvm::JIT::getOrEmitGlobalVariable(), and getPointerToGlobal().
| virtual void llvm::ExecutionEngine::finalizeObject | ( | ) | [inline, virtual] |
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 legacy JIT engine or the interpeter.
Reimplemented in llvm::MCJIT.
Definition at line 263 of file ExecutionEngine/ExecutionEngine.h.
| Function * ExecutionEngine::FindFunctionNamed | ( | const char * | FnName | ) |
FindFunctionNamed - Search all of the active modules to find the one that defines FnName. This is very slow operation and shouldn't be used for general code.
Definition at line 133 of file ExecutionEngine.cpp.
References F(), Modules, and llvm::SmallVectorTemplateCommon< T, typename >::size().
| virtual void llvm::ExecutionEngine::freeMachineCodeForFunction | ( | Function * | F | ) | [pure virtual] |
freeMachineCodeForFunction - Release memory in the ExecutionEngine corresponding to the machine code emitted to execute this function, useful for garbage-collecting generated code.
Implemented in llvm::JIT, llvm::Interpreter, and llvm::MCJIT.
| GenericValue ExecutionEngine::getConstantValue | ( | const Constant * | C | ) | [protected] |
Converts a Constant* into a GenericValue, including handling of ConstantExpr values.
Definition at line 544 of file ExecutionEngine.cpp.
References llvm::APFloat::add(), llvm::GenericValue::AggregateVal, llvm::APIntOps::And(), llvm::lltok::APFloat, llvm::APFloat::bitcastToAPInt(), llvm::APInt::bitsToDouble(), llvm::APInt::bitsToFloat(), llvm::CallingConv::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::LibFunc::fmod, llvm::Type::FP128TyID, llvm::FPExt, llvm::FPToSI, getBitWidth(), llvm::APInt::getBitWidth(), llvm::ConstantDataSequential::getElementAsDouble(), llvm::ConstantDataSequential::getElementAsFloat(), llvm::ConstantDataSequential::getElementAsInteger(), llvm::SequentialType::getElementType(), llvm::ConstantDataSequential::getElementType(), llvm::VectorType::getNumElements(), llvm::ConstantDataSequential::getNumElements(), llvm::User::getOperand(), getOrEmitGlobalVariable(), llvm::DataLayout::getPointerSizeInBits(), getPointerToBasicBlock(), getPointerToFunctionOrStub(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::DataLayout::getTypeSizeInBits(), llvm::APFloat::getZero(), llvm::APInt::getZExtValue(), llvm::Type::IntegerTyID, llvm::IntToPtr, llvm::GenericValue::IntVal, llvm::Type::isDoubleTy(), llvm::Type::isFloatingPointTy(), llvm::Type::isFloatTy(), llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::Type::isX86_FP80Ty(), llvm_unreachable, llvm::APFloat::mod(), llvm::APFloat::multiply(), llvm::APIntOps::Or(), llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::report_fatal_error(), llvm::APFloat::rmNearestTiesToEven, llvm::APFloat::rmTowardZero, llvm::APIntOps::RoundDoubleToAPInt(), llvm::APIntOps::RoundFloatToAPInt(), llvm::APInt::roundToDouble(), llvm::APInt::sdiv(), llvm::SExt, llvm::APInt::sext(), llvm::APInt::signedRoundToDouble(), llvm::SIToFP, llvm::APInt::srem(), llvm::raw_svector_ostream::str(), llvm::APFloat::subtract(), llvm::Trunc, llvm::APInt::trunc(), llvm::APInt::udiv(), llvm::APInt::urem(), llvm::Type::VectorTyID, llvm::Type::X86_FP80TyID, llvm::APFloat::x87DoubleExtended, llvm::APIntOps::Xor(), llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().
Referenced by InitializeMemory().
| const DataLayout* llvm::ExecutionEngine::getDataLayout | ( | ) | const [inline] |
Definition at line 219 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::Interpreter::callExternalFunction(), EmitGlobalVariable(), getMemoryForGV(), llvm::JIT::getMemoryForGV(), InitializeMemory(), isTargetNullPtr(), lle_X_sprintf(), LoadValueFromMemory(), and StoreValueToMemory().
| const GlobalValue * ExecutionEngine::getGlobalValueAtAddress | ( | void * | Addr | ) |
getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.
Definition at line 230 of file ExecutionEngine.cpp.
References llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), I, and lock.
| char * ExecutionEngine::getMemoryForGV | ( | const GlobalVariable * | GV | ) | [protected, virtual] |
getMemoryforGV - Allocate memory for a global variable.
Reimplemented in llvm::JIT.
Definition at line 116 of file ExecutionEngine.cpp.
References getDataLayout().
Referenced by emitGlobals(), and EmitGlobalVariable().
| virtual void* llvm::ExecutionEngine::getOrEmitGlobalVariable | ( | const GlobalVariable * | GV | ) | [inline, virtual] |
getOrEmitGlobalVariable - Return the address of the specified global variable, possibly emitting it to memory if needed. This is used by the Emitter.
Reimplemented in llvm::JIT.
Definition at line 369 of file ExecutionEngine/ExecutionEngine.h.
References getPointerToGlobal().
Referenced by getConstantValue().
| virtual void* llvm::ExecutionEngine::getPointerToBasicBlock | ( | BasicBlock * | BB | ) | [pure virtual] |
getPointerToBasicBlock - The different EE's represent basic blocks in different ways. Return the representation for a blockaddress of the specified block.
Implemented in llvm::JIT, and llvm::MCJIT.
Referenced by getConstantValue().
| virtual void* llvm::ExecutionEngine::getPointerToFunction | ( | Function * | F | ) | [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.
Implemented in llvm::JIT, and llvm::MCJIT.
Referenced by getPointerToFunctionOrStub(), and getPointerToGlobal().
| virtual void* llvm::ExecutionEngine::getPointerToFunctionOrStub | ( | Function * | F | ) | [inline, virtual] |
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.
Reimplemented in llvm::JIT.
Definition at line 332 of file ExecutionEngine/ExecutionEngine.h.
References getPointerToFunction().
Referenced by getConstantValue().
| 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.
Definition at line 524 of file ExecutionEngine.cpp.
References EmitGlobalVariable(), F(), llvm::ExecutionEngineState::getGlobalAddressMap(), getPointerToFunction(), llvm_unreachable, lock, and P.
Referenced by getOrEmitGlobalVariable().
| void * ExecutionEngine::getPointerToGlobalIfAvailable | ( | const GlobalValue * | GV | ) |
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 222 of file ExecutionEngine.cpp.
References llvm::ExecutionEngineState::getGlobalAddressMap(), I, and lock.
Referenced by llvm::Interpreter::callExternalFunction(), emitGlobals(), EmitGlobalVariable(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToFunction(), llvm::JIT::getPointerToFunctionOrStub(), and llvm::JIT::recompileAndRelinkFunction().
| virtual void* llvm::ExecutionEngine::getPointerToNamedFunction | ( | const std::string & | Name, |
| bool | AbortOnFailure = true |
||
| ) | [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.
Implemented in llvm::JIT, llvm::Interpreter, and llvm::MCJIT.
| void ExecutionEngine::InitializeMemory | ( | const Constant * | Init, |
| void * | Addr | ||
| ) |
Definition at line 1118 of file ExecutionEngine.cpp.
References llvm::StringRef::data(), llvm::object::macho::Data, llvm::dbgs(), DEBUG, llvm::Value::dump(), getConstantValue(), getDataLayout(), llvm::StructLayout::getElementOffset(), llvm::DataLayout::getStructLayout(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::Type::isFirstClassType(), llvm_unreachable, llvm::LibFunc::memcpy, llvm::LibFunc::memset, llvm::StringRef::size(), and StoreValueToMemory().
Referenced by EmitGlobalVariable().
| void llvm::ExecutionEngine::InstallExceptionTableDeregister | ( | EERegisterFn | F | ) | [inline] |
Definition at line 443 of file ExecutionEngine/ExecutionEngine.h.
References ExceptionTableDeregister, and F().
| void llvm::ExecutionEngine::InstallExceptionTableRegister | ( | EERegisterFn | F | ) | [inline] |
InstallExceptionTableRegister - The JIT will use the given function to register the exception tables it generates.
Definition at line 440 of file ExecutionEngine/ExecutionEngine.h.
References ExceptionTableRegister, and F().
| void llvm::ExecutionEngine::InstallLazyFunctionCreator | ( | void *(*)(const std::string &) | P | ) | [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 434 of file ExecutionEngine/ExecutionEngine.h.
References LazyFunctionCreator, and P.
| bool llvm::ExecutionEngine::isCompilingLazily | ( | ) | const [inline] |
Definition at line 402 of file ExecutionEngine/ExecutionEngine.h.
| bool llvm::ExecutionEngine::isGVCompilationDisabled | ( | ) | const [inline] |
Definition at line 417 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::JIT::getMemoryForGV().
| bool llvm::ExecutionEngine::isLazyCompilationDisabled | ( | ) | const [inline] |
Definition at line 407 of file ExecutionEngine/ExecutionEngine.h.
| bool llvm::ExecutionEngine::isSymbolSearchingDisabled | ( | ) | const [inline] |
Definition at line 427 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::MCJIT::getPointerToNamedFunction(), and llvm::JIT::getPointerToNamedFunction().
| void ExecutionEngine::LoadValueFromMemory | ( | GenericValue & | Result, |
| GenericValue * | Ptr, | ||
| Type * | Ty | ||
| ) | [protected] |
FIXME: document
Definition at line 1057 of file ExecutionEngine.cpp.
References llvm::GenericValue::AggregateVal, llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, getBitWidth(), getDataLayout(), llvm::SequentialType::getElementType(), llvm::VectorType::getNumElements(), llvm::Type::getTypeID(), llvm::DataLayout::getTypeStoreSize(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, LoadIntFromMemory(), llvm::LibFunc::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().
| virtual void llvm::ExecutionEngine::mapSectionAddress | ( | const void * | LocalAddress, |
| uint64_t | TargetAddress | ||
| ) | [inline, virtual] |
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::MCJIT.
Definition at line 250 of file ExecutionEngine/ExecutionEngine.h.
References llvm_unreachable.
| virtual void* llvm::ExecutionEngine::recompileAndRelinkFunction | ( | Function * | F | ) | [pure virtual] |
recompileAndRelinkFunction - This method is used to force a function which has already been compiled to be compiled again, possibly after it has been modified. Then the entry to the old copy is overwritten with a branch to the new copy. If there was no old copy, this acts just like VM::getPointerToFunction().
Implemented in llvm::JIT, llvm::Interpreter, and llvm::MCJIT.
| virtual void llvm::ExecutionEngine::RegisterJITEventListener | ( | JITEventListener * | ) | [inline, virtual] |
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::JIT, and llvm::MCJIT.
Definition at line 377 of file ExecutionEngine/ExecutionEngine.h.
| void llvm::ExecutionEngine::RegisterTable | ( | const Function * | fn, |
| void * | res | ||
| ) | [inline] |
RegisterTable - Registers the given pointer as an exception table. It uses the ExceptionTableRegister function.
Definition at line 449 of file ExecutionEngine/ExecutionEngine.h.
References AllExceptionTables, and ExceptionTableRegister.
removeModule - Remove a Module from the list of modules. Returns true if M is found.
Reimplemented in llvm::JIT.
Definition at line 120 of file ExecutionEngine.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), clearGlobalMappingsFromModule(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SmallVectorImpl< T >::erase(), I, and Modules.
| virtual GenericValue llvm::ExecutionEngine::runFunction | ( | Function * | F, |
| const std::vector< GenericValue > & | ArgValues | ||
| ) | [pure virtual] |
runFunction - Execute the specified function with the specified arguments, and return the result.
Implemented in llvm::JIT, llvm::Interpreter, and llvm::MCJIT.
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 354 of file ExecutionEngine.cpp.
References 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 void llvm::ExecutionEngine::runJITOnFunction | ( | Function * | , |
| MachineCodeInfo * | = 0 |
||
| ) | [inline, virtual] |
Reimplemented in llvm::JIT.
Definition at line 338 of file ExecutionEngine/ExecutionEngine.h.
| void ExecutionEngine::runStaticConstructorsDestructors | ( | bool | isDtors | ) |
runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.
| isDtors | - Run the destructors instead of constructors. |
Definition at line 337 of file ExecutionEngine.cpp.
References Modules, and llvm::SmallVectorTemplateCommon< T, typename >::size().
runStaticConstructorsDestructors - 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 298 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(), and runFunction().
| void llvm::ExecutionEngine::setDataLayout | ( | const DataLayout * | td | ) | [inline, protected] |
Definition at line 129 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::Interpreter::Interpreter().
| virtual void llvm::ExecutionEngine::setObjectCache | ( | ObjectCache * | ) | [inline, virtual] |
Sets the pre-compiled object cache. The ownership of the ObjectCache is not changed. Supported by MCJIT but not JIT.
Reimplemented in llvm::MCJIT.
Definition at line 382 of file ExecutionEngine/ExecutionEngine.h.
References llvm_unreachable.
| 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 981 of file ExecutionEngine.cpp.
References llvm::GenericValue::AggregateVal, llvm::dbgs(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, getDataLayout(), llvm::APInt::getRawData(), llvm::Type::getTypeID(), llvm::DataLayout::getTypeStoreSize(), if(), llvm::Type::IntegerTyID, llvm::GenericValue::IntVal, llvm::sys::IsLittleEndianHost, llvm::LibFunc::memcpy, llvm::LibFunc::memset, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, StoreIntToMemory(), llvm::Type::VectorTyID, and llvm::Type::X86_FP80TyID.
Referenced by InitializeMemory(), and llvm::Interpreter::visitStoreInst().
| virtual void llvm::ExecutionEngine::UnregisterJITEventListener | ( | JITEventListener * | ) | [inline, virtual] |
Reimplemented in llvm::JIT, and llvm::MCJIT.
Definition at line 378 of file ExecutionEngine/ExecutionEngine.h.
| void * 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 195 of file ExecutionEngine.cpp.
References llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), lock, and llvm::ExecutionEngineState::RemoveMapping().
Referenced by llvm::JIT::freeMachineCodeForFunction().
friend class EngineBuilder [friend] |
Definition at line 122 of file ExecutionEngine/ExecutionEngine.h.
Referenced by create().
DenseMap<const Function*, void*> llvm::ExecutionEngine::AllExceptionTables [protected] |
This maps functions to their exception tables frames.
Definition at line 162 of file ExecutionEngine/ExecutionEngine.h.
Referenced by DeregisterAllTables(), DeregisterTable(), and RegisterTable().
Definition at line 160 of file ExecutionEngine/ExecutionEngine.h.
Referenced by DeregisterAllTables(), DeregisterTable(), and InstallExceptionTableDeregister().
Definition at line 159 of file ExecutionEngine/ExecutionEngine.h.
Referenced by InstallExceptionTableRegister(), and RegisterTable().
ExecutionEngine *(* ExecutionEngine::InterpCtor)(Module *M, std::string *ErrorStr)=0 [static, protected] |
Definition at line 149 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create(), and llvm::Interpreter::Register().
ExecutionEngine *(* ExecutionEngine::JITCtor)(Module *M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM)=0 [static, protected] |
Definition at line 137 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create(), createJIT(), and llvm::JIT::Register().
void*(* llvm::ExecutionEngine::LazyFunctionCreator)(const std::string &) [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 154 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::MCJIT::getPointerToNamedFunction(), llvm::JIT::getPointerToNamedFunction(), and InstallLazyFunctionCreator().
lock - This lock protects the ExecutionEngine, JIT, JITResolver and JITEmitter classes. It must be held while changing the internal state of any of those classes.
Definition at line 169 of file ExecutionEngine/ExecutionEngine.h.
Referenced by addGlobalMapping(), llvm::JIT::addModule(), llvm::JIT::addPendingFunction(), llvm::JIT::addPointerToBasicBlock(), clearAllGlobalMappings(), clearGlobalMappingsFromModule(), llvm::JIT::clearPointerToBasicBlock(), llvm::MCJIT::emitObject(), getGlobalValueAtAddress(), llvm::JIT::getMemoryForGV(), llvm::ExecutionEngineState::AddressMapConfig::getMutex(), llvm::JIT::getOrEmitGlobalVariable(), llvm::JIT::getPointerToBasicBlock(), llvm::JIT::getPointerToFunction(), getPointerToGlobal(), getPointerToGlobalIfAvailable(), llvm::MCJIT::loadObject(), llvm::JIT::NotifyFreeingMachineCode(), llvm::MCJIT::NotifyFreeingObject(), llvm::JIT::NotifyFunctionEmitted(), llvm::MCJIT::NotifyObjectEmitted(), llvm::MCJIT::RegisterJITEventListener(), llvm::JIT::RegisterJITEventListener(), llvm::JIT::removeModule(), llvm::JIT::runJITOnFunction(), llvm::MCJIT::UnregisterJITEventListener(), llvm::JIT::UnregisterJITEventListener(), and updateGlobalMapping().
ExecutionEngine *(* ExecutionEngine::MCJITCtor)(Module *M, std::string *ErrorStr, RTDyldMemoryManager *MCJMM, bool GVsWithCode, TargetMachine *TM)=0 [static, protected] |
Definition at line 143 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::EngineBuilder::create(), and llvm::MCJIT::Register().
SmallVector<Module*, 1> llvm::ExecutionEngine::Modules [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 127 of file ExecutionEngine/ExecutionEngine.h.
Referenced by llvm::JIT::addModule(), addModule(), emitGlobals(), ExecutionEngine(), FindFunctionNamed(), llvm::JIT::removeModule(), removeModule(), runStaticConstructorsDestructors(), and ~ExecutionEngine().