class MCJIT

Declaration

class MCJIT : public 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/lib/ExecutionEngine/MCJIT/MCJIT.h:66

Inherits from: ExecutionEngine

Member Variables

private std::unique_ptr<TargetMachine> TM
private llvm::MCContext* Ctx
private std::shared_ptr<MCJITMemoryManager> MemMgr
private llvm::LinkingSymbolResolver Resolver
private llvm::RuntimeDyld Dyld
private std::vector<JITEventListener*> EventListeners
private llvm::MCJIT::OwningModuleContainer OwnedModules
private SmallVector<object::OwningBinary<object::Archive>, 2> Archives
private SmallVector<std::unique_ptr<MemoryBuffer>, 2> Buffers
private SmallVector<std::unique_ptr<object::ObjectFile>, 2> LoadedObjects
private llvm::ObjectCache* ObjCache

Inherited from ExecutionEngine:

protected Modules
protected LazyFunctionCreator
protected ErrMsg
public lock
protected static MCJITCtor
protected static InterpCtor

Method Overview

Inherited from ExecutionEngine:

Methods

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/lib/ExecutionEngine/MCJIT/MCJIT.h:216

Parameters

llvm::StringRef FnName

llvm::Function* FindFunctionNamedInModulePtrSet(
    llvm::StringRef FnName,
    ModulePtrSet::iterator I,
    ModulePtrSet::iterator E)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:189

Parameters

llvm::StringRef FnName
ModulePtrSet::iterator I
ModulePtrSet::iterator E

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/lib/ExecutionEngine/MCJIT/MCJIT.h:221

Parameters

llvm::StringRef Name
bool AllowInternal = false

llvm::GlobalVariable*
FindGlobalVariableNamedInModulePtrSet(
    llvm::StringRef Name,
    bool AllowInternal,
    ModulePtrSet::iterator I,
    ModulePtrSet::iterator E)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:193

Parameters

llvm::StringRef Name
bool AllowInternal
ModulePtrSet::iterator I
ModulePtrSet::iterator E

MCJIT(std::unique_ptr<Module> M,
      std::unique_ptr<TargetMachine> tm,
      std::shared_ptr<MCJITMemoryManager> MemMgr,
      std::shared_ptr<LegacyJITSymbolResolver>
          Resolver)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:67

Parameters

std::unique_ptr<Module> M
std::unique_ptr<TargetMachine> tm
std::shared_ptr<MCJITMemoryManager> MemMgr
std::shared_ptr<LegacyJITSymbolResolver> Resolver

static void Register()

Description

@ } @ {

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:291

void RegisterJITEventListener(
    llvm::JITEventListener* L)

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/lib/ExecutionEngine/MCJIT/MCJIT.h:276

Parameters

llvm::JITEventListener* L

void UnregisterJITEventListener(
    llvm::JITEventListener* L)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:277

Parameters

llvm::JITEventListener* L

void addArchive(
    object::OwningBinary<object::Archive> O)

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/lib/ExecutionEngine/MCJIT/MCJIT.h:210

Parameters

object::OwningBinary<object::Archive> O

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

Description

@ {

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:207

Parameters

std::unique_ptr<Module> M

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

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:209

Parameters

object::OwningBinary<object::ObjectFile> O

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/lib/ExecutionEngine/MCJIT/MCJIT.h:208

Parameters

std::unique_ptr<object::ObjectFile> O

static llvm::ExecutionEngine* createJIT(
    std::unique_ptr<Module> M,
    std::string* ErrorStr,
    std::shared_ptr<MCJITMemoryManager> MemMgr,
    std::shared_ptr<LegacyJITSymbolResolver>
        Resolver,
    std::unique_ptr<TargetMachine> TM)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:296

Parameters

std::unique_ptr<Module> M
std::string* ErrorStr
std::shared_ptr<MCJITMemoryManager> MemMgr
std::shared_ptr<LegacyJITSymbolResolver> Resolver
std::unique_ptr<TargetMachine> TM

std::unique_ptr<MemoryBuffer> emitObject(
    llvm::Module* M)

Description

emitObject -- Generate a JITed object in memory from the specified module Currently, MCJIT only supports a single module and the module passed to this function call is expected to be the contained module. The module is passed as a parameter here to prepare for multiple module support in the future.

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:323

Parameters

llvm::Module* M

void finalizeLoadedModules()

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:244

virtual void finalizeModule(llvm::Module*)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:243

Parameters

llvm::Module*

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. Is it OK to finalize a set of modules, add modules and finalize again.

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:242

llvm::JITSymbol findExistingSymbol(
    const std::string& Name)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:329

Parameters

const std::string& Name

llvm::Module* findModuleForSymbol(
    const std::string& Name,
    bool CheckFunctionsOnly)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:330

Parameters

const std::string& Name
bool CheckFunctionsOnly

llvm::JITSymbol findSymbol(
    const std::string& Name,
    bool CheckFunctionsOnly)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:305

Parameters

const std::string& Name
bool CheckFunctionsOnly

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/lib/ExecutionEngine/MCJIT/MCJIT.h:231

Parameters

llvm::Module* M

uint64_t getFunctionAddress(
    const std::string& Name)

Description

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

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:283

Parameters

const std::string& Name

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/lib/ExecutionEngine/MCJIT/MCJIT.h:282

Parameters

const std::string& Name

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/lib/ExecutionEngine/MCJIT/MCJIT.h:252

Parameters

llvm::Function* F

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.

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:265

Parameters

llvm::StringRef Name
bool AbortOnFailure = true

uint64_t getSymbolAddress(const std::string& Name,
                          bool CheckFunctionsOnly)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:314

Parameters

const std::string& Name
bool CheckFunctionsOnly

llvm::TargetMachine* getTargetMachine()

Description

Return the target machine (if available).

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:285

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/lib/ExecutionEngine/MCJIT/MCJIT.h:272

Parameters

const void* LocalAddress
uint64_t TargetAddress

void notifyFreeingObject(
    const object::ObjectFile& Obj)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:327

Parameters

const object::ObjectFile& Obj

void notifyObjectLoaded(
    const object::ObjectFile& Obj,
    const RuntimeDyld::LoadedObjectInfo& L)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:325

Parameters

const object::ObjectFile& Obj
const RuntimeDyld::LoadedObjectInfo& L

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/lib/ExecutionEngine/MCJIT/MCJIT.h:211

Parameters

llvm::Module* M

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/lib/ExecutionEngine/MCJIT/MCJIT.h:254

Parameters

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

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/lib/ExecutionEngine/MCJIT/MCJIT.h:250

Parameters

bool isDtors
- Run the destructors instead of constructors.

void runStaticConstructorsDestructorsInModulePtrSet(
    bool isDtors,
    ModulePtrSet::iterator I,
    ModulePtrSet::iterator E)

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:198

Parameters

bool isDtors
ModulePtrSet::iterator I
ModulePtrSet::iterator E

void setObjectCache(llvm::ObjectCache* manager)

Description

Sets the object manager that MCJIT should use to avoid compilation.

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:225

Parameters

llvm::ObjectCache* manager

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/lib/ExecutionEngine/MCJIT/MCJIT.h:227

Parameters

bool ProcessAllSections

~MCJIT()

Declared at: llvm/lib/ExecutionEngine/MCJIT/MCJIT.h:203