LLVM  6.0.0svn
Classes | Public Member Functions | Static Public Member Functions | List of all members
llvm::orc::OrcMCJITReplacement Class Reference

#include "ExecutionEngine/Orc/OrcMCJITReplacement.h"

Inheritance diagram for llvm::orc::OrcMCJITReplacement:
Inheritance graph
[legend]
Collaboration diagram for llvm::orc::OrcMCJITReplacement:
Collaboration graph
[legend]

Public Member Functions

 OrcMCJITReplacement (std::shared_ptr< MCJITMemoryManager > MemMgr, std::shared_ptr< JITSymbolResolver > ClientResolver, std::unique_ptr< TargetMachine > TM)
 
void addModule (std::unique_ptr< Module > M) override
 Add a Module to the list of modules that we can JIT from. More...
 
void addObjectFile (std::unique_ptr< object::ObjectFile > O) override
 addObjectFile - Add an ObjectFile to the execution engine. More...
 
void addObjectFile (object::OwningBinary< object::ObjectFile > O) override
 
void addArchive (object::OwningBinary< object::Archive > A) override
 addArchive - Add an Archive to the execution engine. More...
 
bool removeModule (Module *M) override
 removeModule - Removes a Module from the list of modules, but does not free the module's memory. More...
 
uint64_t getSymbolAddress (StringRef Name)
 
JITSymbol findSymbol (StringRef Name)
 
void finalizeObject () override
 finalizeObject - ensure the module is fully processed and is usable. More...
 
void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress) override
 mapSectionAddress - map a section to its target address space value. More...
 
uint64_t getGlobalValueAddress (const std::string &Name) override
 getGlobalValueAddress - Return the address of the specified global value. More...
 
uint64_t getFunctionAddress (const std::string &Name) override
 getFunctionAddress - Return the address of the specified function. More...
 
void * getPointerToFunction (Function *F) override
 getPointerToFunction - The different EE's represent function bodies in different ways. More...
 
void * getPointerToNamedFunction (StringRef Name, bool AbortOnFailure=true) override
 getPointerToNamedFunction - This method returns the address of the specified function by using the dlsym function call. More...
 
GenericValue runFunction (Function *F, ArrayRef< GenericValue > ArgValues) override
 runFunction - Execute the specified function with the specified arguments, and return the result. More...
 
void setObjectCache (ObjectCache *NewCache) override
 Sets the pre-compiled object cache. More...
 
void setProcessAllSections (bool ProcessAllSections) override
 setProcessAllSections (MCJIT Only): By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded. More...
 
void runStaticConstructorsDestructors (bool isDtors) override
 runStaticConstructorsDestructors - This method is used to execute all of the static constructors or destructors for a program. More...
 
- Public Member Functions inherited from llvm::ExecutionEngine
virtual ~ExecutionEngine ()
 
const DataLayoutgetDataLayout () const
 
virtual FunctionFindFunctionNamed (StringRef FnName)
 FindFunctionNamed - Search all of the active modules to find the function that defines FnName. More...
 
virtual GlobalVariableFindGlobalVariableNamed (StringRef Name, bool AllowInternal=false)
 FindGlobalVariableNamed - Search all of the active modules to find the global variable that defines Name. More...
 
virtual void generateCodeForModule (Module *M)
 generateCodeForModule - Run code generation for the specified module and load it into memory. More...
 
void runStaticConstructorsDestructors (Module &module, bool isDtors)
 This method is used to execute all of the static constructors or destructors for a particular module. More...
 
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. More...
 
void addGlobalMapping (const GlobalValue *GV, void *Addr)
 addGlobalMapping - Tell the execution engine that the specified global is at the specified location. More...
 
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. More...
 
void clearGlobalMappingsFromModule (Module *M)
 clearGlobalMappingsFromModule - Clear all global mappings that came from a particular module, because it has been removed from the JIT. More...
 
uint64_t updateGlobalMapping (const GlobalValue *GV, void *Addr)
 updateGlobalMapping - Replace an existing mapping for GV with a new address. More...
 
uint64_t updateGlobalMapping (StringRef Name, uint64_t Addr)
 
uint64_t getAddressToGlobalIfAvailable (StringRef S)
 getAddressToGlobalIfAvailable - This returns the address of the specified global symbol. More...
 
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. More...
 
void * getPointerToGlobalIfAvailable (const GlobalValue *GV)
 
void * getPointerToGlobal (const GlobalValue *GV)
 getPointerToGlobal - This returns the address of the specified global value. More...
 
virtual void * getPointerToFunctionOrStub (Function *F)
 getPointerToFunctionOrStub - If the specified function has been code-gen'd, return a pointer to the function. More...
 
const GlobalValuegetGlobalValueAtAddress (void *Addr)
 getGlobalValueAtAddress - Return the LLVM global value object that starts at the specified address. More...
 
void StoreValueToMemory (const GenericValue &Val, GenericValue *Ptr, Type *Ty)
 StoreValueToMemory - Stores the data in Val of type Ty at address Ptr. More...
 
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. More...
 
virtual void RegisterJITEventListener (JITEventListener *)
 Registers a listener to be called back on various events within the JIT. More...
 
virtual void UnregisterJITEventListener (JITEventListener *)
 
virtual TargetMachinegetTargetMachine ()
 Return the target machine (if available). More...
 
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. More...
 
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. More...
 
bool isGVCompilationDisabled () const
 
void DisableSymbolSearching (bool Disabled=true)
 DisableSymbolSearching - If called, the JIT will not try to lookup unknown symbols with dlsym. More...
 
bool isSymbolSearchingDisabled () const
 
void setVerifyModules (bool Verify)
 Enable/Disable IR module verification. More...
 
bool getVerifyModules () const
 
void InstallLazyFunctionCreator (FunctionCreator C)
 InstallLazyFunctionCreator - If an unknown function is needed, the specified function pointer is invoked to create it. More...
 

Static Public Member Functions

static void Register ()
 

Additional Inherited Members

- Public Attributes inherited from llvm::ExecutionEngine
sys::Mutex lock
 lock - This lock protects the ExecutionEngine and MCJIT classes. More...
 
- Protected Member Functions inherited from llvm::ExecutionEngine
virtual chargetMemoryForGV (const GlobalVariable *GV)
 getMemoryforGV - Allocate memory for a global variable. More...
 
std::string getMangledName (const GlobalValue *GV)
 getMangledName - Get mangled name. More...
 
 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. More...
 
void EmitGlobalVariable (const GlobalVariable *GV)
 
GenericValue getConstantValue (const Constant *C)
 Converts a Constant* into a GenericValue, including handling of ConstantExpr values. More...
 
void LoadValueFromMemory (GenericValue &Result, GenericValue *Ptr, Type *Ty)
 FIXME: document. More...
 
- Protected Attributes inherited from llvm::ExecutionEngine
SmallVector< std::unique_ptr< Module >, 1 > Modules
 The list of Modules that we are JIT'ing from. More...
 
FunctionCreator LazyFunctionCreator
 LazyFunctionCreator - If an unknown function is needed, this function pointer is invoked to create it. More...
 
- Static Protected Attributes inherited from llvm::ExecutionEngine
static ExecutionEngine *(* MCJITCtor )(std::unique_ptr< Module > M, std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< JITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM) = nullptr
 
static ExecutionEngine *(* OrcMCJITReplacementCtor )(std::string *ErrorStr, std::shared_ptr< MCJITMemoryManager > MM, std::shared_ptr< JITSymbolResolver > SR, std::unique_ptr< TargetMachine > TM) = nullptr
 
static ExecutionEngine *(* InterpCtor )(std::unique_ptr< Module > M, std::string *ErrorStr) =nullptr
 

Detailed Description

Definition at line 56 of file OrcMCJITReplacement.h.

Constructor & Destructor Documentation

◆ OrcMCJITReplacement()

llvm::orc::OrcMCJITReplacement::OrcMCJITReplacement ( std::shared_ptr< MCJITMemoryManager MemMgr,
std::shared_ptr< JITSymbolResolver ClientResolver,
std::unique_ptr< TargetMachine TM 
)
inline

Definition at line 170 of file OrcMCJITReplacement.h.

Member Function Documentation

◆ addArchive()

void llvm::orc::OrcMCJITReplacement::addArchive ( object::OwningBinary< object::Archive A)
inlineoverridevirtual

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 221 of file OrcMCJITReplacement.h.

◆ addModule()

void llvm::orc::OrcMCJITReplacement::addModule ( std::unique_ptr< Module M)
inlineoverridevirtual

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 189 of file OrcMCJITReplacement.h.

References assert(), llvm::cantFail(), llvm::ExecutionEngine::getDataLayout(), and I.

◆ addObjectFile() [1/2]

void llvm::orc::OrcMCJITReplacement::addObjectFile ( std::unique_ptr< object::ObjectFile O)
inlineoverridevirtual

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 208 of file OrcMCJITReplacement.h.

References llvm::cantFail().

◆ addObjectFile() [2/2]

void llvm::orc::OrcMCJITReplacement::addObjectFile ( object::OwningBinary< object::ObjectFile O)
inlineoverridevirtual

Reimplemented from llvm::ExecutionEngine.

Definition at line 215 of file OrcMCJITReplacement.h.

References llvm::cantFail().

◆ finalizeObject()

void llvm::orc::OrcMCJITReplacement::finalizeObject ( )
inlineoverridevirtual

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.

Reimplemented from llvm::ExecutionEngine.

Definition at line 244 of file OrcMCJITReplacement.h.

◆ findSymbol()

JITSymbol llvm::orc::OrcMCJITReplacement::findSymbol ( StringRef  Name)
inline

Definition at line 240 of file OrcMCJITReplacement.h.

Referenced by getSymbolAddress().

◆ getFunctionAddress()

uint64_t llvm::orc::OrcMCJITReplacement::getFunctionAddress ( const std::string &  Name)
inlineoverridevirtual

getFunctionAddress - Return the address of the specified function.

This may involve code generation.

Reimplemented from llvm::ExecutionEngine.

Definition at line 260 of file OrcMCJITReplacement.h.

References getSymbolAddress().

◆ getGlobalValueAddress()

uint64_t llvm::orc::OrcMCJITReplacement::getGlobalValueAddress ( const std::string &  Name)
inlineoverridevirtual

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 256 of file OrcMCJITReplacement.h.

References getSymbolAddress().

◆ getPointerToFunction()

void* llvm::orc::OrcMCJITReplacement::getPointerToFunction ( Function F)
inlineoverridevirtual

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 264 of file OrcMCJITReplacement.h.

References llvm::Value::getName(), and getSymbolAddress().

◆ getPointerToNamedFunction()

void* llvm::orc::OrcMCJITReplacement::getPointerToNamedFunction ( StringRef  Name,
bool  AbortOnFailure = true 
)
inlineoverridevirtual

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.

Implements llvm::ExecutionEngine.

Definition at line 269 of file OrcMCJITReplacement.h.

References F(), getSymbolAddress(), llvm_unreachable, and runFunction().

◆ getSymbolAddress()

uint64_t llvm::orc::OrcMCJITReplacement::getSymbolAddress ( StringRef  Name)
inline

◆ mapSectionAddress()

void llvm::orc::OrcMCJITReplacement::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)
inlineoverridevirtual

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 249 of file OrcMCJITReplacement.h.

References P.

◆ Register()

static void llvm::orc::OrcMCJITReplacement::Register ( )
inlinestatic

◆ removeModule()

bool llvm::orc::OrcMCJITReplacement::removeModule ( Module M)
inlineoverridevirtual

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

Definition at line 225 of file OrcMCJITReplacement.h.

References E, and I.

◆ runFunction()

GenericValue llvm::orc::OrcMCJITReplacement::runFunction ( Function F,
ArrayRef< GenericValue ArgValues 
)
overridevirtual

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

Implements llvm::ExecutionEngine.

Definition at line 27 of file OrcMCJITReplacement.cpp.

References assert(), DoubleTyID, llvm::GenericValue::DoubleVal, llvm::ArrayRef< T >::empty(), FloatTyID, llvm::GenericValue::FloatVal, getBitWidth(), llvm::Function::getFunctionType(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::FunctionType::getReturnType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::GenericValue::IntVal, llvm::tgtok::IntVal, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::PTOGV(), and llvm::ArrayRef< T >::size().

Referenced by getPointerToNamedFunction().

◆ runStaticConstructorsDestructors()

void llvm::orc::OrcMCJITReplacement::runStaticConstructorsDestructors ( bool  isDtors)
overridevirtual

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 127 of file OrcMCJITReplacement.cpp.

Referenced by setProcessAllSections().

◆ setObjectCache()

void llvm::orc::OrcMCJITReplacement::setObjectCache ( ObjectCache )
inlineoverridevirtual

Sets the pre-compiled object cache.

The ownership of the ObjectCache is not changed. Supported by MCJIT but not the interpreter.

Reimplemented from llvm::ExecutionEngine.

Definition at line 280 of file OrcMCJITReplacement.h.

◆ setProcessAllSections()

void llvm::orc::OrcMCJITReplacement::setProcessAllSections ( bool  ProcessAllSections)
inlineoverridevirtual

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 284 of file OrcMCJITReplacement.h.

References llvm::cantFail(), llvm::consumeError(), llvm::object::Archive::findSym(), llvm::Expected< T >::get(), llvm::ExecutionEngine::getDataLayout(), H, llvm::X86II::OB, llvm::report_fatal_error(), runStaticConstructorsDestructors(), and llvm::Expected< T >::takeError().


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