LLVM API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions
llvm::JIT Class Reference

#include <JIT.h>

Inheritance diagram for llvm::JIT:
Inheritance graph
Collaboration diagram for llvm::JIT:
Collaboration graph

List of all members.

Public Member Functions

 ~JIT ()
TargetJITInfogetJITInfo () const
void addModule (std::unique_ptr< Module > M) override
bool removeModule (Module *M) override
GenericValue runFunction (Function *F, const std::vector< GenericValue > &ArgValues) override
void * getPointerToNamedFunction (const std::string &Name, bool AbortOnFailure=true) override
void * getPointerToFunction (Function *F) override
void addPointerToBasicBlock (const BasicBlock *BB, void *Addr)
 addPointerToBasicBlock - Adds address of the specific basic block.
void clearPointerToBasicBlock (const BasicBlock *BB)
 clearPointerToBasicBlock - Removes address of specific basic block.
void * getPointerToBasicBlock (BasicBlock *BB) override
void * getOrEmitGlobalVariable (const GlobalVariable *GV) override
void * getPointerToFunctionOrStub (Function *F) override
void * recompileAndRelinkFunction (Function *F) override
void freeMachineCodeForFunction (Function *F) override
void addPendingFunction (Function *F)
JITCodeEmittergetCodeEmitter () const
void runJITOnFunction (Function *F, MachineCodeInfo *MCI=nullptr) override
void RegisterJITEventListener (JITEventListener *L) override
void UnregisterJITEventListener (JITEventListener *L) override
TargetMachinegetTargetMachine () override
 Return the target machine (if available).
void NotifyFunctionEmitted (const Function &F, void *Code, size_t Size, const JITEvent_EmittedFunctionDetails &Details)
void NotifyFreeingMachineCode (void *OldPtr)
BasicBlockAddressMapTygetBasicBlockAddressMap ()

Static Public Member Functions

static void Register ()
static void CompilationCallback ()
static ExecutionEnginecreateJIT (std::unique_ptr< Module > M, std::string *ErrorStr, JITMemoryManager *JMM, bool GVsWithCode, TargetMachine *TM)

Protected Member Functions

char * getMemoryForGV (const GlobalVariable *GV) override
 getMemoryforGV - Allocate memory for a global variable.

Detailed Description

Definition at line 53 of file lib/ExecutionEngine/JIT/JIT.h.

Constructor & Destructor Documentation

JIT::~JIT ( )

Definition at line 167 of file JIT.cpp.

Member Function Documentation

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

addPendingFunction - while jitting non-lazily, a called but non-codegen'd function was encountered. Add it to a pending list to be processed after the current function.

Definition at line 688 of file JIT.cpp.

References llvm::JITState::getPendingFunctions(), and llvm::ExecutionEngine::lock.

void JIT::addPointerToBasicBlock ( const BasicBlock BB,
void *  Addr 

addPointerToBasicBlock - Adds address of the specific basic block.

Definition at line 535 of file JIT.cpp.

References llvm::sys::path::end(), llvm::ValueMap< KeyT, ValueT, Config >::find(), getBasicBlockAddressMap(), I, and llvm::ExecutionEngine::lock.

clearPointerToBasicBlock - Removes address of specific basic block.

Definition at line 547 of file JIT.cpp.

References llvm::ValueMap< KeyT, ValueT, Config >::erase(), getBasicBlockAddressMap(), and llvm::ExecutionEngine::lock.

static void llvm::JIT::CompilationCallback ( ) [static]
ExecutionEngine * JIT::createJIT ( std::unique_ptr< Module M,
std::string *  ErrorStr,
JITMemoryManager JMM,
bool  GVsWithCode,
TargetMachine TM 
) [static]

This is the factory method for creating a JIT for the current machine, it does not fall back to the interpreter.

Definition at line 74 of file JIT.cpp.

References llvm::TargetSubtargetInfo::getJITInfo(), llvm::TargetMachine::getSubtargetImpl(), and llvm::sys::DynamicLibrary::LoadLibraryPermanently().

Referenced by Register().

void JIT::freeMachineCodeForFunction ( Function F) [override, virtual]

freeMachineCodeForFunction - deallocate memory used to code-generate this Function.

freeMachineCodeForFunction - release machine code memory for given Function.

Implements llvm::ExecutionEngine.

Definition at line 1241 of file JITEmitter.cpp.

References llvm::ExecutionEngine::updateGlobalMapping().

getCodeEmitter - Return the code emitter this JIT is emitting into.

Definition at line 168 of file lib/ExecutionEngine/JIT/JIT.h.

Referenced by getPointerToFunctionOrStub().

TargetJITInfo& llvm::JIT::getJITInfo ( ) const [inline]

getJITInfo - Return the target JIT information structure.

Definition at line 92 of file lib/ExecutionEngine/JIT/JIT.h.

char * JIT::getMemoryForGV ( const GlobalVariable GV) [override, protected, virtual]
void * JIT::getOrEmitGlobalVariable ( const GlobalVariable GV) [override, virtual]
void * JIT::getPointerToBasicBlock ( BasicBlock BB) [override, virtual]
void * JIT::getPointerToFunction ( Function F) [override, virtual]

getPointerToFunction - This returns the address of the specified function, compiling it if necessary.

getPointerToFunction - This method is used to get the address of the specified function, compiling it if necessary.

Implements llvm::ExecutionEngine.

Definition at line 502 of file JIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), llvm::Value::getName(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), getPointerToNamedFunction(), llvm::GlobalValue::hasAvailableExternallyLinkage(), llvm::GlobalValue::hasExternalWeakLinkage(), llvm::GlobalValue::isDeclaration(), llvm::ExecutionEngine::lock, llvm::GlobalValue::Materialize(), and llvm::report_fatal_error().

Referenced by getPointerToBasicBlock(), recompileAndRelinkFunction(), and runFunction().

void * JIT::getPointerToFunctionOrStub ( Function F) [override, virtual]

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.

Reimplemented from llvm::ExecutionEngine.

Definition at line 1214 of file JITEmitter.cpp.

References getCodeEmitter(), and llvm::ExecutionEngine::getPointerToGlobalIfAvailable().

void * JIT::getPointerToNamedFunction ( const std::string &  Name,
bool  AbortOnFailure = true 
) [override, virtual]

getPointerToNamedFunction - This method returns the address of the specified function by using the MemoryManager. 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 569 of file JIT.cpp.

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

Referenced by getPointerToFunction().

TargetMachine* llvm::JIT::getTargetMachine ( ) [inline, override, virtual]

Return the target machine (if available).

Reimplemented from llvm::ExecutionEngine.

Definition at line 182 of file lib/ExecutionEngine/JIT/JIT.h.

void JIT::NotifyFreeingMachineCode ( void *  OldPtr)

Definition at line 434 of file JIT.cpp.

References I, and llvm::ExecutionEngine::lock.

void JIT::NotifyFunctionEmitted ( const Function F,
void *  Code,
size_t  Size,
const JITEvent_EmittedFunctionDetails Details 

These functions correspond to the methods on JITEventListener. They iterate over the registered listeners and call the corresponding method on each.

Definition at line 424 of file JIT.cpp.

References I, and llvm::ExecutionEngine::lock.

Referenced by runJITOnFunction().

void * JIT::recompileAndRelinkFunction ( Function F) [override, virtual]

recompileAndRelinkFunction - This method is used to force a function which has already been compiled, to be compiled again, possibly after it has been modified. Then the entry to the old copy is overwritten with a branch to the new copy. If there was no old copy, this acts just like JIT::getPointerToFunction().

Implements llvm::ExecutionEngine.

Definition at line 627 of file JIT.cpp.

References llvm::ExecutionEngine::addGlobalMapping(), getPointerToFunction(), llvm::ExecutionEngine::getPointerToGlobalIfAvailable(), llvm::TargetJITInfo::replaceMachineCodeForFunction(), and runJITOnFunction().

static void llvm::JIT::Register ( ) [inline, static]

Definition at line 86 of file lib/ExecutionEngine/JIT/JIT.h.

References createJIT(), and llvm::ExecutionEngine::JITCtor.

void JIT::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 407 of file JIT.cpp.

References llvm::ExecutionEngine::lock.

Referenced by runJITOnFunction().

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

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

If we are removing the last Module, invalidate the jitstate since the PassManager it contains references a released Module.

Reimplemented from llvm::ExecutionEngine.

Definition at line 205 of file JIT.cpp.

References llvm::TargetMachine::addPassesToEmitMachineCode(), llvm::SmallVectorBase::empty(), llvm::TargetSubtargetInfo::getDataLayout(), llvm::JITState::getModule(), llvm::JITState::getPM(), llvm::TargetMachine::getSubtargetImpl(), llvm::ExecutionEngine::getVerifyModules(), llvm::ExecutionEngine::lock, llvm::ExecutionEngine::Modules, llvm::report_fatal_error(), and llvm::Module::setDataLayout().

GenericValue JIT::runFunction ( Function F,
const std::vector< GenericValue > &  ArgValues 
) [override, virtual]

runFunction - Start execution with the specified function and arguments.

run - Start execution with the specified function and arguments.

Implements llvm::ExecutionEngine.

Definition at line 236 of file JIT.cpp.

References llvm::lltok::APFloat, llvm::CallingConv::C, llvm::BasicBlock::Create(), llvm::Function::Create(), llvm::CallInst::Create(), llvm::ReturnInst::Create(), llvm::Type::DoubleTyID, llvm::GenericValue::DoubleVal, llvm::Function::eraseFromParent(), llvm::Type::FloatTyID, llvm::GenericValue::FloatVal, llvm::Type::FP128TyID, llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::ConstantFP::get(), getBitWidth(), llvm::Function::getCallingConv(), llvm::Function::getContext(), llvm::Type::getFltSemantics(), llvm::Function::getFunctionType(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::ConstantExpr::getIntToPtr(), llvm::FunctionType::getNumParams(), llvm::FunctionType::getParamType(), llvm::GlobalValue::getParent(), getPointerToFunction(), llvm::FunctionType::getReturnType(), llvm::Value::getType(), llvm::Type::getTypeID(), llvm::GVTOP(), llvm::Type::IntegerTyID, llvm::GlobalValue::InternalLinkage, llvm::GenericValue::IntVal, llvm::tgtok::IntVal, llvm::Type::isIntegerTy(), llvm::Type::isPointerTy(), llvm::FunctionType::isVarArg(), llvm::Type::isVoidTy(), llvm_unreachable, llvm::Type::PointerTyID, llvm::Type::PPC_FP128TyID, llvm::PTOGV(), llvm::CallInst::setCallingConv(), llvm::CallInst::setTailCall(), llvm::Type::VoidTyID, and llvm::Type::X86_FP80TyID.

void JIT::runJITOnFunction ( Function F,
MachineCodeInfo MCI = nullptr 
) [override, virtual]

runJITOnFunction - Run the FunctionPassManager full of just-in-time compilation passes on F, hopefully filling in GlobalAddress[F] with the address of F's machine code.

Reimplemented from llvm::ExecutionEngine.

Definition at line 445 of file JIT.cpp.

References llvm::tgtok::Code, llvm::ExecutionEngine::lock, NotifyFunctionEmitted(), RegisterJITEventListener(), llvm::MachineCodeInfo::setAddress(), llvm::MachineCodeInfo::setSize(), and UnregisterJITEventListener().

Referenced by recompileAndRelinkFunction().

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

Reimplemented from llvm::ExecutionEngine.

Definition at line 413 of file JIT.cpp.

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

Referenced by runJITOnFunction().

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