LLVM API Documentation

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::MCJIT Class Reference

#include <MCJIT.h>

Inheritance diagram for llvm::MCJIT:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCJIT:
Collaboration graph
[legend]

List of all members.

Classes

class  OwningModuleContainer

Public Member Functions

 ~MCJIT ()
uint64_t getSymbolAddress (const std::string &Name, bool CheckFunctionsOnly)
ExecutionEngine interface implementation
void addModule (std::unique_ptr< Module > M) override
 Add a Module to the list of modules that we can JIT from.
void addObjectFile (std::unique_ptr< object::ObjectFile > O) override
void addObjectFile (object::OwningBinary< object::ObjectFile > O) override
void addArchive (object::OwningBinary< object::Archive > O) override
bool removeModule (Module *M) override
FunctionFindFunctionNamed (const char *FnName) override
void setObjectCache (ObjectCache *manager) override
 Sets the object manager that MCJIT should use to avoid compilation.
void setProcessAllSections (bool ProcessAllSections) override
void generateCodeForModule (Module *M) override
void finalizeObject () override
virtual void finalizeModule (Module *)
void finalizeLoadedModules ()
void runStaticConstructorsDestructors (bool isDtors) override
void * getPointerToFunction (Function *F) override
GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues) override
void * getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override
void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) override
void RegisterJITEventListener (JITEventListener *L) override
void UnregisterJITEventListener (JITEventListener *L) override
uint64_t getGlobalValueAddress (const std::string &Name) override
uint64_t getFunctionAddress (const std::string &Name) override
TargetMachinegetTargetMachine () override
 Return the target machine (if available).

Static Public Member Functions

static void Register ()
static ExecutionEnginecreateJIT (std::unique_ptr< Module > M, std::string *ErrorStr, RTDyldMemoryManager *MemMgr, std::unique_ptr< TargetMachine > TM)

Protected Member Functions

std::unique_ptr
< ObjectBufferStream
emitObject (Module *M)
void NotifyObjectEmitted (const ObjectImage &Obj)
void NotifyFreeingObject (const ObjectImage &Obj)
uint64_t getExistingSymbolAddress (const std::string &Name)
ModulefindModuleForSymbol (const std::string &Name, bool CheckFunctionsOnly)

Detailed Description

Definition at line 103 of file lib/ExecutionEngine/MCJIT/MCJIT.h.


Constructor & Destructor Documentation


Member Function Documentation

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

Definition at line 117 of file MCJIT.cpp.

References llvm::SmallVectorTemplateBase< T, isPodLike >::push_back().

void MCJIT::addModule ( std::unique_ptr< Module M) [override, virtual]

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 92 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock.

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

Definition at line 102 of file MCJIT.cpp.

References llvm::RuntimeDyld::getErrorString(), llvm::RuntimeDyld::hasError(), llvm::RuntimeDyld::loadObject(), NotifyObjectEmitted(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and llvm::report_fatal_error().

Referenced by addObjectFile(), and getSymbolAddress().

void MCJIT::addObjectFile ( object::OwningBinary< object::ObjectFile O) [override, virtual]
ExecutionEngine * MCJIT::createJIT ( std::unique_ptr< Module M,
std::string *  ErrorStr,
RTDyldMemoryManager MemMgr,
std::unique_ptr< TargetMachine TM 
) [static]

Definition at line 46 of file MCJIT.cpp.

References llvm::sys::DynamicLibrary::LoadLibraryPermanently().

Referenced by Register().

std::unique_ptr< ObjectBufferStream > MCJIT::emitObject ( Module M) [protected]

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.

Definition at line 126 of file MCJIT.cpp.

References llvm::ExecutionEngine::getVerifyModules(), llvm::ExecutionEngine::lock, llvm::ObjectCache::notifyObjectCompiled(), llvm::report_fatal_error(), and llvm::Module::setDataLayout().

Referenced by generateCodeForModule().

void MCJIT::finalizeModule ( Module M) [virtual]
void MCJIT::finalizeObject ( ) [override, 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. Is it OK to finalize a set of modules, add modules and finalize again.

Reimplemented from llvm::ExecutionEngine.

Definition at line 225 of file MCJIT.cpp.

References finalizeLoadedModules(), generateCodeForModule(), llvm::ExecutionEngine::lock, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

Function * MCJIT::FindFunctionNamed ( const char *  FnName) [override, virtual]

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.

Reimplemented from llvm::ExecutionEngine.

Definition at line 408 of file MCJIT.cpp.

References F().

Module * MCJIT::findModuleForSymbol ( const std::string &  Name,
bool  CheckFunctionsOnly 
) [protected]
void MCJIT::generateCodeForModule ( Module M) [override, virtual]

generateCodeForModule - Run code generation for the specified module and load it into memory.

When this function has completed, all code and data for the specified module, and any module on which this module depends, will be generated and loaded into memory, but relocations will not yet have been applied and all memory will be readable and writable but not executable.

This function is primarily useful when generating code for an external target, allowing the client an opportunity to remap section addresses before relocations are applied. Clients that intend to execute code locally can use the getFunctionAddress call, which will generate code and apply final preparations all in one step.

This method has no effect for the interpeter.

Reimplemented from llvm::ExecutionEngine.

Definition at line 165 of file MCJIT.cpp.

References emitObject(), llvm::RuntimeDyld::getErrorString(), llvm::ObjectCache::getObject(), llvm::RuntimeDyld::loadObject(), llvm::ExecutionEngine::lock, NotifyObjectEmitted(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and llvm::report_fatal_error().

Referenced by finalizeModule(), finalizeObject(), getPointerToFunction(), and getSymbolAddress().

uint64_t MCJIT::getExistingSymbolAddress ( const std::string &  Name) [protected]

Definition at line 253 of file MCJIT.cpp.

References llvm::RuntimeDyld::getSymbolLoadAddress().

Referenced by getSymbolAddress().

uint64_t MCJIT::getFunctionAddress ( const std::string &  Name) [override, virtual]

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 342 of file MCJIT.cpp.

References finalizeLoadedModules(), getSymbolAddress(), and llvm::ExecutionEngine::lock.

uint64_t MCJIT::getGlobalValueAddress ( const std::string &  Name) [override, virtual]

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 from llvm::ExecutionEngine.

Definition at line 334 of file MCJIT.cpp.

References finalizeLoadedModules(), getSymbolAddress(), and llvm::ExecutionEngine::lock.

void * MCJIT::getPointerToFunction ( Function F) [override, 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.

Implements llvm::ExecutionEngine.

Definition at line 351 of file MCJIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), generateCodeForModule(), llvm::Value::getName(), llvm::GlobalValue::getParent(), getPointerToNamedFunction(), llvm::RuntimeDyld::getSymbolLoadAddress(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::isDeclaration(), llvm::ExecutionEngine::lock, and Name.

Referenced by runFunction().

void * MCJIT::getPointerToNamedFunction ( StringRef  Name,
bool  AbortOnFailure = true 
) [override, 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.

If a LazyFunctionCreator is installed, use it to get/create the function.

Implements llvm::ExecutionEngine.

Definition at line 520 of file MCJIT.cpp.

References llvm::RTDyldMemoryManager::getPointerToNamedFunction(), llvm::ExecutionEngine::isSymbolSearchingDisabled(), llvm::ExecutionEngine::LazyFunctionCreator, llvm::report_fatal_error(), and llvm::NVPTX::PTXCvtMode::RP.

Referenced by getPointerToFunction().

uint64_t MCJIT::getSymbolAddress ( const std::string &  Name,
bool  CheckFunctionsOnly 
)
TargetMachine* llvm::MCJIT::getTargetMachine ( ) [inline, override, virtual]

Return the target machine (if available).

Reimplemented from llvm::ExecutionEngine.

Definition at line 316 of file lib/ExecutionEngine/MCJIT/MCJIT.h.

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

Definition at line 303 of file lib/ExecutionEngine/MCJIT/MCJIT.h.

References llvm::RuntimeDyld::mapSectionAddress().

void MCJIT::NotifyFreeingObject ( const ObjectImage Obj) [protected]

Definition at line 562 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock.

Referenced by ~MCJIT().

void MCJIT::NotifyObjectEmitted ( const ObjectImage Obj) [protected]
static void llvm::MCJIT::Register ( ) [inline, static]
void MCJIT::RegisterJITEventListener ( JITEventListener ) [override, 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 from llvm::ExecutionEngine.

Definition at line 539 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock.

bool MCJIT::removeModule ( Module M) [override, virtual]

removeModule - Remove a Module from the list of modules. Returns true if M is found.

Reimplemented from llvm::ExecutionEngine.

Definition at line 97 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock.

GenericValue MCJIT::runFunction ( Function F,
const std::vector< GenericValue > &  ArgValues 
) [override, virtual]
void MCJIT::runStaticConstructorsDestructors ( bool  isDtors) [override, 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 from llvm::ExecutionEngine.

Definition at line 388 of file MCJIT.cpp.

void MCJIT::setObjectCache ( ObjectCache manager) [override, virtual]

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 121 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock.

void llvm::MCJIT::setProcessAllSections ( bool  ProcessAllSections) [inline, override, virtual]

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 from llvm::ExecutionEngine.

Definition at line 258 of file lib/ExecutionEngine/MCJIT/MCJIT.h.

References llvm::RuntimeDyld::setProcessAllSections().

void MCJIT::UnregisterJITEventListener ( JITEventListener L) [override, virtual]

Reimplemented from llvm::ExecutionEngine.

Definition at line 545 of file MCJIT.cpp.

References llvm::ExecutionEngine::lock, and std::swap().


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