class ExecutionEngine

Declaration

class ExecutionEngine { /* full declaration omitted */ };

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:99

Member Variables

private llvm::ExecutionEngineState EEState
The state object holding the global address mapping, which must be accessed synchronously.
private const llvm::DataLayout DL
Note: the DataLayout is LLVMContext specific because it has an internal cache based on type pointers. It makes unsafe to reuse the ExecutionEngine across context, we don't enforce this rule but undefined behavior can occurs if the user tries to do it.
private bool CompilingLazily
Whether lazy JIT compilation is enabled.
private bool GVCompilationDisabled
Whether JIT compilation of external global variables is allowed.
private bool SymbolSearchingDisabled
Whether the JIT should perform lookups of external symbols (e.g., using dlsym).
private bool VerifyModules
Whether the JIT should verify IR modules during compilation.
protected SmallVector<std::unique_ptr<Module>, 1> Modules
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.
protected llvm::FunctionCreator LazyFunctionCreator
LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. If this returns null, the JIT will abort.
protected std::string ErrMsg
public sys::Mutex lock
lock - This lock protects the ExecutionEngine and MCJIT classes. It must be held while changing the internal state of any of those classes.
protected static llvm:: ExecutionEngine* (*)(std::unique_ptr<Module>, std::string*, std::shared_ptr< MCJITMemoryManager>, std::shared_ptr< LegacyJITSymbolResolver>, std::unique_ptr< TargetMachine>) MCJITCtor
protected static llvm::ExecutionEngine* (*)(std::unique_ptr< Module>, std::string*) InterpCtor

Method Overview

Methods

void DisableGVCompilation(bool Disabled = true)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:468

Parameters

bool Disabled = true

void DisableLazyCompilation(bool Disabled = true)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:458

Parameters

bool Disabled = true

void DisableSymbolSearching(bool Disabled = true)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:478

Parameters

bool Disabled = true

ExecutionEngine(llvm::DataLayout DL)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:504

Parameters

llvm::DataLayout DL

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:505

Parameters

llvm::DataLayout DL
std::unique_ptr<Module> M

ExecutionEngine(std::unique_ptr<Module> M)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:506

Parameters

std::unique_ptr<Module> M

virtual llvm::Function* FindFunctionNamed(
    llvm::StringRef FnName)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:209

Parameters

llvm::StringRef FnName

virtual llvm::GlobalVariable*
FindGlobalVariableNamed(
    llvm::StringRef Name,
    bool AllowInternal = false)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:214

Parameters

llvm::StringRef Name
bool AllowInternal = false

void Init(std::unique_ptr<Module> M)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:517

Parameters

std::unique_ptr<Module> M

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:402

Parameters

const llvm::Constant* Init
void* Addr

void InstallLazyFunctionCreator(
    llvm::FunctionCreator C)

Description

InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. If it returns null, the JIT will abort.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:499

Parameters

llvm::FunctionCreator C

void LoadValueFromMemory(
    llvm::GenericValue& Result,
    llvm::GenericValue* Ptr,
    llvm::Type* Ty)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:513

Parameters

llvm::GenericValue& Result
llvm::GenericValue* Ptr
llvm::Type* Ty

virtual void RegisterJITEventListener(
    llvm::JITEventListener*)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:418

Parameters

llvm::JITEventListener*

void StoreValueToMemory(
    const llvm::GenericValue& Val,
    llvm::GenericValue* Ptr,
    llvm::Type* Ty)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:399

Parameters

const llvm::GenericValue& Val
llvm::GenericValue* Ptr
llvm::Type* Ty

virtual void UnregisterJITEventListener(
    llvm::JITEventListener*)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:419

Parameters

llvm::JITEventListener*

virtual void addArchive(
    object::OwningBinary<object::Archive> A)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:192

Parameters

object::OwningBinary<object::Archive> A

void addGlobalMapping(const llvm::GlobalValue* GV,
                      void* Addr)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:315

Parameters

const llvm::GlobalValue* GV
void* Addr

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:316

Parameters

llvm::StringRef Name
uint64_t Addr

virtual void addModule(std::unique_ptr<Module> M)

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:169

Parameters

std::unique_ptr<Module> M

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:184

Parameters

object::OwningBinary<object::ObjectFile> O

virtual void addObjectFile(
    std::unique_ptr<object::ObjectFile> O)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:183

Parameters

std::unique_ptr<object::ObjectFile> O

void clearAllGlobalMappings()

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:320

void clearErrorMessage()

Description

Clear the error message.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:283

void clearGlobalMappingsFromModule(
    llvm::Module* M)

Description

clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:324

Parameters

llvm::Module* M

void emitGlobalVariable(
    const llvm::GlobalVariable* GV)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:510

Parameters

const llvm::GlobalVariable* GV

void emitGlobals()

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:508

virtual void finalizeObject()

Description

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. Returns true on success, false on failure. Error messages can be retrieved by calling getError();

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:277

virtual void generateCodeForModule(
    llvm::Module* M)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:265

Parameters

llvm::Module* M

uint64_t getAddressToGlobalIfAvailable(
    llvm::StringRef S)

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:335

Parameters

llvm::StringRef S

llvm::GenericValue getConstantValue(
    const llvm::Constant* C)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:512

Parameters

const llvm::Constant* C

const llvm::DataLayout& getDataLayout() const

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:196

const std::string& getErrorMessage() const

Description

Returns the most recent error message.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:286

virtual uint64_t getFunctionAddress(
    const std::string& Name)

Description

getFunctionAddress - Return the address of the specified function. This may involve code generation.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:384

Parameters

const std::string& Name

virtual uint64_t getGlobalValueAddress(
    const std::string& Name)

Description

getGlobalValueAddress - Return the address of the specified global value. This may involve code generation. This function should not be called with the interpreter engine.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:376

Parameters

const std::string& Name

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

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:393

Parameters

void* Addr

std::string getMangledName(
    const llvm::GlobalValue* GV)

Description

getMangledName - Get mangled name.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:153

Parameters

const llvm::GlobalValue* GV

virtual char* getMemoryForGV(
    const llvm::GlobalVariable* GV)

Description

getMemoryforGV - Allocate memory for a global variable.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:136

Parameters

const llvm::GlobalVariable* GV

virtual void* getOrEmitGlobalVariable(
    const llvm::GlobalVariable* GV)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:410

Parameters

const llvm::GlobalVariable* GV

virtual void* getPointerToFunction(
    llvm::Function* F)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:358

Parameters

llvm::Function* F

virtual void* getPointerToFunctionOrStub(
    llvm::Function* F)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:367

Parameters

llvm::Function* F

void* getPointerToGlobal(
    const llvm::GlobalValue* GV)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:348

Parameters

const llvm::GlobalValue* GV

void* getPointerToGlobalIfAvailable(
    const llvm::GlobalValue* GV)

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:341

Parameters

const llvm::GlobalValue* GV

void* getPointerToGlobalIfAvailable(
    llvm::StringRef S)

Description

getPointerToGlobalIfAvailable - This returns the address of the specified global value if it is has already been codegen'd, otherwise it returns null.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:340

Parameters

llvm::StringRef S

virtual void* getPointerToNamedFunction(
    llvm::StringRef Name,
    bool AbortOnFailure = true)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:237

Parameters

llvm::StringRef Name
bool AbortOnFailure = true

virtual llvm::TargetMachine* getTargetMachine()

Description

Return the target machine (if available).

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:443

bool getVerifyModules() const

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:492

bool hasError() const

Description

Returns true if an error has been recorded.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:280

bool isCompilingLazily() const

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:461

bool isGVCompilationDisabled() const

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:471

bool isSymbolSearchingDisabled() const

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:481

virtual void mapSectionAddress(
    const void* LocalAddress,
    uint64_t TargetAddress)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:244

Parameters

const void* LocalAddress
uint64_t TargetAddress

virtual bool removeModule(llvm::Module* M)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:204

Parameters

llvm::Module* M

virtual llvm::GenericValue runFunction(
    llvm::Function* F,
    ArrayRef<llvm::GenericValue> ArgValues)

Description

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*[])).

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:225

Parameters

llvm::Function* F
ArrayRef<llvm::GenericValue> ArgValues

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

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:304

Parameters

llvm::Function* Fn
const std::vector<std::string>& argv
const char* const* envp

void runStaticConstructorsDestructors(
    llvm::Module& module,
    bool isDtors)

Description

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:298

Parameters

llvm::Module& module
bool isDtors
- Run the destructors instead of constructors.

virtual void runStaticConstructorsDestructors(
    bool isDtors)

Description

runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:292

Parameters

bool isDtors
- Run the destructors instead of constructors.

virtual void setObjectCache(llvm::ObjectCache*)

Description

Sets the pre-compiled object cache. The ownership of the ObjectCache is not changed. Supported by MCJIT but not the interpreter.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:423

Parameters

llvm::ObjectCache*

virtual void setProcessAllSections(
    bool ProcessAllSections)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:438

Parameters

bool ProcessAllSections

void setVerifyModules(bool Verify)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:489

Parameters

bool Verify

uint64_t updateGlobalMapping(
    const llvm::GlobalValue* GV,
    void* Addr)

Description

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.

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:330

Parameters

const llvm::GlobalValue* GV
void* Addr

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

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:331

Parameters

llvm::StringRef Name
uint64_t Addr

virtual ~ExecutionEngine()

Declared at: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:166