LLVM 20.0.0git
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
llvm::ExecutionEngine Class Referenceabstract

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"

Inheritance diagram for llvm::ExecutionEngine:
Inheritance graph
[legend]

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.
 
virtual void addObjectFile (std::unique_ptr< object::ObjectFile > O)
 addObjectFile - Add an ObjectFile to the execution engine.
 
virtual void addObjectFile (object::OwningBinary< object::ObjectFile > O)
 
virtual void addArchive (object::OwningBinary< object::Archive > A)
 addArchive - Add an Archive to the execution engine.
 
const DataLayoutgetDataLayout () const
 
virtual bool removeModule (Module *M)
 removeModule - Removes a Module from the list of modules, but does not free the module's memory.
 
virtual FunctionFindFunctionNamed (StringRef FnName)
 FindFunctionNamed - Search all of the active modules to find the function that defines FnName.
 
virtual GlobalVariableFindGlobalVariableNamed (StringRef Name, bool AllowInternal=false)
 FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name.
 
virtual GenericValue runFunction (Function *F, ArrayRef< GenericValue > ArgValues)=0
 runFunction - Execute the specified function with the specified arguments, and return the result.
 
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.
 
virtual void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
 mapSectionAddress - map a section to its target address space value.
 
virtual void generateCodeForModule (Module *M)
 generateCodeForModule - Run code generation for the specified module and load it into memory.
 
virtual void finalizeObject ()
 finalizeObject - ensure the module is fully processed and is usable.
 
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.
 
virtual void runStaticConstructorsDestructors (bool isDtors)
 runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.
 
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 * getPointerToFunction (Function *F)=0
 getPointerToFunction - The different EE's represent function bodies in different ways.
 
virtual void * getPointerToFunctionOrStub (Function *F)
 getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function.
 
virtual uint64_t getGlobalValueAddress (const std::string &Name)
 getGlobalValueAddress - Return the address of the specified global value.
 
virtual uint64_t getFunctionAddress (const std::string &Name)
 getFunctionAddress - Return the address of the specified function.
 
const GlobalValuegetGlobalValueAtAddress (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.
 
virtual void RegisterJITEventListener (JITEventListener *)
 Registers a listener to be called back on various events within the JIT.
 
virtual void UnregisterJITEventListener (JITEventListener *)
 
virtual void setObjectCache (ObjectCache *)
 Sets the pre-compiled object cache.
 
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.
 
virtual TargetMachinegetTargetMachine ()
 Return the target machine (if available).
 
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.
 

Public Attributes

sys::Mutex lock
 lock - This lock protects the ExecutionEngine and MCJIT classes.
 

Protected Member Functions

virtual chargetMemoryForGV (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

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

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
 

Friends

class EngineBuilder
 

Detailed Description

Abstract interface for implementation execution of LLVM modules, designed to support both interpreter and just-in-time (JIT) compiler implementations.

Definition at line 99 of file ExecutionEngine.h.

Constructor & Destructor Documentation

◆ ~ExecutionEngine()

ExecutionEngine::~ExecutionEngine ( )
virtual

Definition at line 90 of file ExecutionEngine.cpp.

References clearAllGlobalMappings().

◆ ExecutionEngine() [1/3]

llvm::ExecutionEngine::ExecutionEngine ( DataLayout  DL)
inlineprotected

Definition at line 504 of file ExecutionEngine.h.

◆ ExecutionEngine() [2/3]

ExecutionEngine::ExecutionEngine ( DataLayout  DL,
std::unique_ptr< Module M 
)
explicitprotected

Definition at line 85 of file ExecutionEngine.cpp.

◆ ExecutionEngine() [3/3]

ExecutionEngine::ExecutionEngine ( std::unique_ptr< Module M)
explicitprotected

Definition at line 80 of file ExecutionEngine.cpp.

Member Function Documentation

◆ addArchive()

void ExecutionEngine::addArchive ( object::OwningBinary< object::Archive A)
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::MCJIT.

Definition at line 136 of file ExecutionEngine.cpp.

References llvm_unreachable.

◆ addGlobalMapping() [1/2]

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 203 of file ExecutionEngine.cpp.

References addGlobalMapping(), Addr, getMangledName(), and lock.

Referenced by addGlobalMapping(), emitGlobals(), and emitGlobalVariable().

◆ addGlobalMapping() [2/2]

void ExecutionEngine::addGlobalMapping ( StringRef  Name,
uint64_t  Addr 
)

◆ addModule()

virtual void llvm::ExecutionEngine::addModule ( std::unique_ptr< Module M)
inlinevirtual

Add a Module to the list of modules that we can JIT from.

Reimplemented in llvm::MCJIT.

Definition at line 169 of file ExecutionEngine.h.

References Modules.

◆ addObjectFile() [1/2]

void ExecutionEngine::addObjectFile ( object::OwningBinary< object::ObjectFile O)
virtual

Reimplemented in llvm::MCJIT.

Definition at line 132 of file ExecutionEngine.cpp.

References llvm_unreachable.

◆ addObjectFile() [2/2]

void ExecutionEngine::addObjectFile ( std::unique_ptr< object::ObjectFile O)
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::MCJIT.

Definition at line 127 of file ExecutionEngine.cpp.

References llvm_unreachable.

◆ clearAllGlobalMappings()

void ExecutionEngine::clearAllGlobalMappings ( )

clearAllGlobalMappings - Clear all global mappings and start over again, for use in dynamic compilation scenarios to move globals.

Definition at line 227 of file ExecutionEngine.cpp.

References llvm::StringMap< ValueTy, AllocatorTy >::clear(), llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), and lock.

Referenced by ~ExecutionEngine().

◆ clearErrorMessage()

void llvm::ExecutionEngine::clearErrorMessage ( )
inline

Clear the error message.

Definition at line 283 of file ExecutionEngine.h.

References ErrMsg.

◆ clearGlobalMappingsFromModule()

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 234 of file ExecutionEngine.cpp.

References getMangledName(), lock, and llvm::ExecutionEngineState::RemoveMapping().

Referenced by removeModule().

◆ DisableGVCompilation()

void llvm::ExecutionEngine::DisableGVCompilation ( bool  Disabled = true)
inline

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 468 of file ExecutionEngine.h.

References llvm::Disabled.

◆ DisableLazyCompilation()

void llvm::ExecutionEngine::DisableLazyCompilation ( bool  Disabled = true)
inline

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 458 of file ExecutionEngine.h.

References llvm::Disabled.

◆ DisableSymbolSearching()

void llvm::ExecutionEngine::DisableSymbolSearching ( bool  Disabled = true)
inline

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 478 of file ExecutionEngine.h.

References llvm::Disabled.

◆ emitGlobals()

void ExecutionEngine::emitGlobals ( )
protected

◆ emitGlobalVariable()

void ExecutionEngine::emitGlobalVariable ( const GlobalVariable GV)
protected

◆ finalizeObject()

virtual void llvm::ExecutionEngine::finalizeObject ( )
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 interpreter.

Returns true on success, false on failure. Error messages can be retrieved by calling getError();

Reimplemented in llvm::MCJIT.

Definition at line 277 of file ExecutionEngine.h.

◆ FindFunctionNamed()

Function * ExecutionEngine::FindFunctionNamed ( StringRef  FnName)
virtual

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 153 of file ExecutionEngine.cpp.

References F, and Modules.

◆ FindGlobalVariableNamed()

GlobalVariable * ExecutionEngine::FindGlobalVariableNamed ( StringRef  Name,
bool  AllowInternal = false 
)
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 162 of file ExecutionEngine.cpp.

References llvm::GlobalValue::isDeclaration(), Modules, and Name.

◆ generateCodeForModule()

virtual void llvm::ExecutionEngine::generateCodeForModule ( Module M)
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 interpreter.

Reimplemented in llvm::MCJIT.

Definition at line 265 of file ExecutionEngine.h.

◆ getAddressToGlobalIfAvailable()

uint64_t ExecutionEngine::getAddressToGlobalIfAvailable ( StringRef  S)

getAddressToGlobalIfAvailable - This returns the address of the specified global symbol.

Definition at line 274 of file ExecutionEngine.cpp.

References llvm::Address, llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::ExecutionEngineState::getGlobalAddressMap(), I, and lock.

Referenced by getPointerToGlobalIfAvailable().

◆ getConstantValue()

GenericValue ExecutionEngine::getConstantValue ( const Constant C)
protected

Converts a Constant* into a GenericValue, including handling of ConstantExpr values.

Definition at line 585 of file ExecutionEngine.cpp.

References A, llvm::APFloat::add(), llvm::Type::ArrayTyID, assert(), llvm::APFloat::bitcastToAPInt(), llvm::APInt::bitsToDouble(), llvm::APInt::bitsToFloat(), llvm::BitWidth, llvm::CallingConv::C, llvm::APFloat::convertFromAPInt(), llvm::APFloat::convertToInteger(), llvm::APFloat::divide(), llvm::APInt::doubleToBits(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, F, llvm::Type::FixedVectorTyID, llvm::APInt::floatToBits(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::UndefValue::get(), llvm::APInt::getBitWidth(), getConstantValue(), llvm::ConstantDataSequential::getElementAsDouble(), llvm::ConstantDataSequential::getElementAsFloat(), llvm::ConstantDataSequential::getElementAsInteger(), llvm::ConstantDataSequential::getElementType(), llvm::Constant::getNullValue(), llvm::ConstantDataSequential::getNumElements(), llvm::User::getOperand(), getOrEmitGlobalVariable(), llvm::DataLayout::getPointerSizeInBits(), getPointerToFunctionOrStub(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::DataLayout::getTypeSizeInBits(), llvm::APFloat::getZero(), llvm::APInt::getZExtValue(), llvm::TargetExtType::HasZeroInit, ignored(), 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(), LHS, llvm_unreachable, llvm::APFloat::mod(), llvm::APFloat::multiply(), llvm::Offset, OS, llvm::Type::PointerTyID, llvm::GenericValue::PointerVal, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::report_fatal_error(), RHS, llvm::APFloatBase::rmNearestTiesToEven, llvm::APFloatBase::rmTowardZero, llvm::APIntOps::RoundDoubleToAPInt(), llvm::APIntOps::RoundFloatToAPInt(), llvm::APInt::roundToDouble(), llvm::Type::ScalableVectorTyID, llvm::APInt::sext(), llvm::APInt::signedRoundToDouble(), llvm::Type::StructTyID, llvm::APFloat::subtract(), llvm::APInt::trunc(), llvm::Type::X86_FP80TyID, llvm::APFloatBase::x87DoubleExtended(), llvm::APInt::zext(), and llvm::APInt::zextOrTrunc().

Referenced by getConstantValue(), and InitializeMemory().

◆ getDataLayout()

const DataLayout & llvm::ExecutionEngine::getDataLayout ( ) const
inline

◆ getErrorMessage()

const std::string & llvm::ExecutionEngine::getErrorMessage ( ) const
inline

Returns the most recent error message.

Definition at line 286 of file ExecutionEngine.h.

References ErrMsg.

◆ getFunctionAddress()

virtual uint64_t llvm::ExecutionEngine::getFunctionAddress ( const std::string &  Name)
inlinevirtual

getFunctionAddress - Return the address of the specified function.

This may involve code generation.

Reimplemented in llvm::MCJIT.

Definition at line 384 of file ExecutionEngine.h.

◆ getGlobalValueAddress()

virtual uint64_t llvm::ExecutionEngine::getGlobalValueAddress ( const std::string &  Name)
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::MCJIT.

Definition at line 376 of file ExecutionEngine.h.

◆ getGlobalValueAtAddress()

const GlobalValue * ExecutionEngine::getGlobalValueAtAddress ( void *  Addr)

getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address.

Definition at line 297 of file ExecutionEngine.cpp.

References Addr, llvm::StringMap< ValueTy, AllocatorTy >::begin(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::ExecutionEngineState::getGlobalAddressMap(), llvm::ExecutionEngineState::getGlobalAddressReverseMap(), I, lock, Modules, and Name.

◆ getMangledName()

std::string ExecutionEngine::getMangledName ( const GlobalValue GV)
protected

◆ getMemoryForGV()

char * ExecutionEngine::getMemoryForGV ( const GlobalVariable GV)
protectedvirtual

getMemoryforGV - Allocate memory for a global variable.

Definition at line 123 of file ExecutionEngine.cpp.

References getDataLayout().

Referenced by emitGlobals(), and emitGlobalVariable().

◆ getOrEmitGlobalVariable()

virtual void * llvm::ExecutionEngine::getOrEmitGlobalVariable ( const GlobalVariable GV)
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 410 of file ExecutionEngine.h.

References getPointerToGlobal().

Referenced by getConstantValue().

◆ getPointerToFunction()

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.

This function is deprecated for the MCJIT execution engine. Use getFunctionAddress instead.

Implemented in llvm::MCJIT.

Referenced by getPointerToFunctionOrStub(), and getPointerToGlobal().

◆ getPointerToFunctionOrStub()

virtual void * llvm::ExecutionEngine::getPointerToFunctionOrStub ( Function F)
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 367 of file ExecutionEngine.h.

References F, and getPointerToFunction().

Referenced by getConstantValue().

◆ getPointerToGlobal()

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 565 of file ExecutionEngine.cpp.

References emitGlobalVariable(), F, getPointerToFunction(), getPointerToGlobalIfAvailable(), llvm_unreachable, lock, and P.

Referenced by getOrEmitGlobalVariable().

◆ getPointerToGlobalIfAvailable() [1/2]

void * ExecutionEngine::getPointerToGlobalIfAvailable ( const GlobalValue GV)

Definition at line 292 of file ExecutionEngine.cpp.

References getMangledName(), getPointerToGlobalIfAvailable(), and lock.

◆ getPointerToGlobalIfAvailable() [2/2]

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 285 of file ExecutionEngine.cpp.

References llvm::Address, getAddressToGlobalIfAvailable(), and lock.

Referenced by llvm::Interpreter::callExternalFunction(), emitGlobals(), emitGlobalVariable(), llvm::MCJIT::findExistingSymbol(), getPointerToGlobal(), and getPointerToGlobalIfAvailable().

◆ getPointerToNamedFunction()

virtual void * llvm::ExecutionEngine::getPointerToNamedFunction ( StringRef  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.

This function is deprecated for the MCJIT execution engine.

Implemented in llvm::Interpreter, and llvm::MCJIT.

◆ getTargetMachine()

virtual TargetMachine * llvm::ExecutionEngine::getTargetMachine ( )
inlinevirtual

Return the target machine (if available).

Reimplemented in llvm::MCJIT.

Definition at line 443 of file ExecutionEngine.h.

◆ getVerifyModules()

bool llvm::ExecutionEngine::getVerifyModules ( ) const
inline

Definition at line 492 of file ExecutionEngine.h.

Referenced by llvm::MCJIT::emitObject().

◆ hasError()

bool llvm::ExecutionEngine::hasError ( ) const
inline

Returns true if an error has been recorded.

Definition at line 280 of file ExecutionEngine.h.

References ErrMsg.

◆ InitializeMemory()

void ExecutionEngine::InitializeMemory ( const Constant Init,
void *  Addr 
)

◆ InstallLazyFunctionCreator()

void llvm::ExecutionEngine::InstallLazyFunctionCreator ( FunctionCreator  C)
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 499 of file ExecutionEngine.h.

References llvm::CallingConv::C, and LazyFunctionCreator.

◆ isCompilingLazily()

bool llvm::ExecutionEngine::isCompilingLazily ( ) const
inline

Definition at line 461 of file ExecutionEngine.h.

◆ isGVCompilationDisabled()

bool llvm::ExecutionEngine::isGVCompilationDisabled ( ) const
inline

Definition at line 471 of file ExecutionEngine.h.

◆ isSymbolSearchingDisabled()

bool llvm::ExecutionEngine::isSymbolSearchingDisabled ( ) const
inline

◆ LoadValueFromMemory()

void ExecutionEngine::LoadValueFromMemory ( GenericValue Result,
GenericValue Ptr,
Type Ty 
)
protected

◆ mapSectionAddress()

virtual void llvm::ExecutionEngine::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)
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::MCJIT.

Definition at line 244 of file ExecutionEngine.h.

References llvm_unreachable.

◆ RegisterJITEventListener()

virtual void llvm::ExecutionEngine::RegisterJITEventListener ( JITEventListener )
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 418 of file ExecutionEngine.h.

◆ removeModule()

bool ExecutionEngine::removeModule ( Module M)
virtual

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::MCJIT.

Definition at line 140 of file ExecutionEngine.cpp.

References clearGlobalMappingsFromModule(), I, and Modules.

◆ runFunction()

virtual GenericValue llvm::ExecutionEngine::runFunction ( Function F,
ArrayRef< GenericValue ArgValues 
)
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::Interpreter, and llvm::MCJIT.

Referenced by runFunctionAsMain(), and runStaticConstructorsDestructors().

◆ runFunctionAsMain()

int ExecutionEngine::runFunctionAsMain ( Function Fn,
const std::vector< std::string > &  argv,
const char *const envp 
)

◆ runStaticConstructorsDestructors() [1/2]

void ExecutionEngine::runStaticConstructorsDestructors ( bool  isDtors)
virtual

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 in llvm::MCJIT.

Definition at line 406 of file ExecutionEngine.cpp.

References Modules, and runStaticConstructorsDestructors().

Referenced by runStaticConstructorsDestructors().

◆ runStaticConstructorsDestructors() [2/2]

void ExecutionEngine::runStaticConstructorsDestructors ( Module module,
bool  isDtors 
)

This method is used to execute all of the static constructors or destructors for a particular module.

Parameters
isDtors- Run the destructors instead of constructors.

Definition at line 367 of file ExecutionEngine.cpp.

References F, FP, llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::GlobalValue::hasLocalLinkage(), llvm::GlobalValue::isDeclaration(), Name, and runFunction().

◆ setObjectCache()

virtual void llvm::ExecutionEngine::setObjectCache ( ObjectCache )
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::MCJIT.

Definition at line 423 of file ExecutionEngine.h.

References llvm_unreachable.

◆ setProcessAllSections()

virtual void llvm::ExecutionEngine::setProcessAllSections ( bool  ProcessAllSections)
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::MCJIT.

Definition at line 438 of file ExecutionEngine.h.

References llvm_unreachable.

◆ setVerifyModules()

void llvm::ExecutionEngine::setVerifyModules ( bool  Verify)
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 489 of file ExecutionEngine.h.

References Verify.

Referenced by llvm::EngineBuilder::create().

◆ StoreValueToMemory()

void ExecutionEngine::StoreValueToMemory ( const GenericValue Val,
GenericValue Ptr,
Type Ty 
)

◆ UnregisterJITEventListener()

virtual void llvm::ExecutionEngine::UnregisterJITEventListener ( JITEventListener )
inlinevirtual

Reimplemented in llvm::MCJIT.

Definition at line 419 of file ExecutionEngine.h.

◆ updateGlobalMapping() [1/2]

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 241 of file ExecutionEngine.cpp.

References Addr, getMangledName(), lock, and updateGlobalMapping().

Referenced by llvm::MCJIT::getPointerToFunction(), and updateGlobalMapping().

◆ updateGlobalMapping() [2/2]

uint64_t ExecutionEngine::updateGlobalMapping ( StringRef  Name,
uint64_t  Addr 
)

Friends And Related Function Documentation

◆ EngineBuilder

friend class EngineBuilder
friend

Definition at line 128 of file ExecutionEngine.h.

Member Data Documentation

◆ ErrMsg

std::string llvm::ExecutionEngine::ErrMsg
protected

◆ InterpCtor

ExecutionEngine *(* ExecutionEngine::InterpCtor)(std::unique_ptr< Module > M, std::string *ErrorStr) =nullptr
staticprotected

Definition at line 144 of file ExecutionEngine.h.

Referenced by llvm::EngineBuilder::create(), and llvm::Interpreter::Register().

◆ LazyFunctionCreator

FunctionCreator llvm::ExecutionEngine::LazyFunctionCreator
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 150 of file ExecutionEngine.h.

Referenced by llvm::MCJIT::findSymbol(), llvm::MCJIT::getPointerToNamedFunction(), and InstallLazyFunctionCreator().

◆ lock

sys::Mutex llvm::ExecutionEngine::lock

◆ MCJITCtor

ExecutionEngine *(* ExecutionEngine::MCJITCtor)(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< LegacyJITSymbolResolver > Resolver, std::unique_ptr< TargetMachine > TM) = nullptr
staticprotected

Definition at line 138 of file ExecutionEngine.h.

Referenced by llvm::EngineBuilder::create(), and llvm::MCJIT::Register().

◆ Modules

SmallVector<std::unique_ptr<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 133 of file ExecutionEngine.h.

Referenced by addModule(), emitGlobals(), FindFunctionNamed(), FindGlobalVariableNamed(), getGlobalValueAtAddress(), removeModule(), and runStaticConstructorsDestructors().


The documentation for this class was generated from the following files: