LLVM  8.0.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::orc::LLJIT Class Reference

A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT. More...

#include "llvm/ExecutionEngine/Orc/LLJIT.h"

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

Public Member Functions

 ~LLJIT ()
 Destruct this instance. More...
 
ExecutionSessiongetExecutionSession ()
 Returns the ExecutionSession for this instance. More...
 
JITDylibgetMainJITDylib ()
 Returns a reference to the JITDylib representing the JIT'd main program. More...
 
JITDylibcreateJITDylib (std::string Name)
 Create a new JITDylib with the given name and return a reference to it. More...
 
Error defineAbsolute (StringRef Name, JITEvaluatedSymbol Address)
 Convenience method for defining an absolute symbol. More...
 
Error addIRModule (JITDylib &JD, ThreadSafeModule TSM)
 Convenience method for defining an. More...
 
Error addIRModule (ThreadSafeModule TSM)
 Adds an IR module to the Main JITDylib. More...
 
Error addObjectFile (JITDylib &JD, std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib. More...
 
Error addObjectFile (std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib. More...
 
Expected< JITEvaluatedSymbollookupLinkerMangled (JITDylib &JD, StringRef Name)
 Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead). More...
 
Expected< JITEvaluatedSymbollookupLinkerMangled (StringRef Name)
 Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead). More...
 
Expected< JITEvaluatedSymbollookup (JITDylib &JD, StringRef UnmangledName)
 Look up a symbol in JITDylib JD based on its IR symbol name. More...
 
Expected< JITEvaluatedSymbollookup (StringRef UnmangledName)
 Look up a symbol in the main JITDylib based on its IR symbol name. More...
 
Error runConstructors ()
 Runs all not-yet-run static constructors. More...
 
Error runDestructors ()
 Runs all not-yet-run static destructors. More...
 
RTDyldObjectLinkingLayergetObjLinkingLayer ()
 Returns a reference to the ObjLinkingLayer. More...
 

Static Public Member Functions

static Expected< std::unique_ptr< LLJIT > > Create (JITTargetMachineBuilder JTMB, DataLayout DL, unsigned NumCompileThreads=0)
 Create an LLJIT instance. More...
 

Protected Member Functions

 LLJIT (std::unique_ptr< ExecutionSession > ES, std::unique_ptr< TargetMachine > TM, DataLayout DL)
 Create an LLJIT instance with a single compile thread. More...
 
 LLJIT (std::unique_ptr< ExecutionSession > ES, JITTargetMachineBuilder JTMB, DataLayout DL, unsigned NumCompileThreads)
 Create an LLJIT instance with multiple compile threads. More...
 
std::string mangle (StringRef UnmangledName)
 
Error applyDataLayout (Module &M)
 
void recordCtorDtors (Module &M)
 

Protected Attributes

std::unique_ptr< ExecutionSessionES
 
JITDylibMain
 
DataLayout DL
 
std::unique_ptr< ThreadPoolCompileThreads
 
RTDyldObjectLinkingLayer ObjLinkingLayer
 
IRCompileLayer CompileLayer
 
CtorDtorRunner CtorRunner
 
CtorDtorRunner DtorRunner
 

Detailed Description

A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.

Definition at line 32 of file LLJIT.h.

Constructor & Destructor Documentation

◆ ~LLJIT()

llvm::orc::LLJIT::~LLJIT ( )

Destruct this instance.

If a multi-threaded instance, waits for all compile threads to complete.

Definition at line 33 of file LLJIT.cpp.

◆ LLJIT() [1/2]

llvm::orc::LLJIT::LLJIT ( std::unique_ptr< ExecutionSession ES,
std::unique_ptr< TargetMachine TM,
DataLayout  DL 
)
protected

Create an LLJIT instance with a single compile thread.

Definition at line 82 of file LLJIT.cpp.

References CompileLayer, CtorRunner, DtorRunner, ES, Main, ObjLinkingLayer, and llvm::SystemZISD::TM.

Referenced by getObjLinkingLayer().

◆ LLJIT() [2/2]

llvm::orc::LLJIT::LLJIT ( std::unique_ptr< ExecutionSession ES,
JITTargetMachineBuilder  JTMB,
DataLayout  DL,
unsigned  NumCompileThreads 
)
protected

Create an LLJIT instance with multiple compile threads.

Definition at line 92 of file LLJIT.cpp.

References assert(), CompileLayer, CompileThreads, CtorRunner, DtorRunner, ES, Main, ObjLinkingLayer, and llvm::orc::IRLayer::setCloneToNewContextOnEmit().

Member Function Documentation

◆ addIRModule() [1/2]

Error llvm::orc::LLJIT::addIRModule ( JITDylib JD,
ThreadSafeModule  TSM 
)

Convenience method for defining an.

Adds an IR module to the given JITDylib.

Definition at line 62 of file LLJIT.cpp.

References assert().

Referenced by addIRModule(), and createJITDylib().

◆ addIRModule() [2/2]

Error llvm::orc::LLJIT::addIRModule ( ThreadSafeModule  TSM)
inline

Adds an IR module to the Main JITDylib.

Definition at line 66 of file LLJIT.h.

References addIRModule(), addObjectFile(), and Main.

◆ addObjectFile() [1/2]

Error llvm::orc::LLJIT::addObjectFile ( JITDylib JD,
std::unique_ptr< MemoryBuffer Obj 
)

Adds an object file to the given JITDylib.

Definition at line 71 of file LLJIT.cpp.

References assert().

Referenced by addIRModule(), and addObjectFile().

◆ addObjectFile() [2/2]

Error llvm::orc::LLJIT::addObjectFile ( std::unique_ptr< MemoryBuffer Obj)
inline

Adds an object file to the given JITDylib.

Definition at line 74 of file LLJIT.h.

References addObjectFile(), lookupLinkerMangled(), and Main.

◆ applyDataLayout()

Error llvm::orc::LLJIT::applyDataLayout ( Module M)
protected

◆ Create()

Expected< std::unique_ptr< LLJIT > > llvm::orc::LLJIT::Create ( JITTargetMachineBuilder  JTMB,
DataLayout  DL,
unsigned  NumCompileThreads = 0 
)
static

Create an LLJIT instance.

If NumCompileThreads is not equal to zero, creates a multi-threaded LLJIT with the given number of compile threads.

Definition at line 39 of file LLJIT.cpp.

References llvm::orc::JITTargetMachineBuilder::createTargetMachine(), and llvm::SystemZISD::TM.

◆ createJITDylib()

JITDylib& llvm::orc::LLJIT::createJITDylib ( std::string  Name)
inline

Create a new JITDylib with the given name and return a reference to it.

Definition at line 53 of file LLJIT.h.

References addIRModule(), llvm::Address, defineAbsolute(), ES, and Name.

◆ defineAbsolute()

Error llvm::orc::LLJIT::defineAbsolute ( StringRef  Name,
JITEvaluatedSymbol  Address 
)

Convenience method for defining an absolute symbol.

Definition at line 56 of file LLJIT.cpp.

References llvm::orc::absoluteSymbols().

Referenced by createJITDylib().

◆ getExecutionSession()

ExecutionSession& llvm::orc::LLJIT::getExecutionSession ( )
inline

Returns the ExecutionSession for this instance.

Definition at line 47 of file LLJIT.h.

References ES.

◆ getMainJITDylib()

JITDylib& llvm::orc::LLJIT::getMainJITDylib ( )
inline

Returns a reference to the JITDylib representing the JIT'd main program.

Definition at line 50 of file LLJIT.h.

References Main.

◆ getObjLinkingLayer()

RTDyldObjectLinkingLayer& llvm::orc::LLJIT::getObjLinkingLayer ( )
inline

Returns a reference to the ObjLinkingLayer.

Definition at line 107 of file LLJIT.h.

References applyDataLayout(), ES, LLJIT(), mangle(), ObjLinkingLayer, recordCtorDtors(), and llvm::SystemZISD::TM.

◆ lookup() [1/2]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookup ( JITDylib JD,
StringRef  UnmangledName 
)
inline

Look up a symbol in JITDylib JD based on its IR symbol name.

Definition at line 91 of file LLJIT.h.

References lookupLinkerMangled(), and mangle().

Referenced by lookup().

◆ lookup() [2/2]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookup ( StringRef  UnmangledName)
inline

Look up a symbol in the main JITDylib based on its IR symbol name.

Definition at line 96 of file LLJIT.h.

References lookup(), and Main.

◆ lookupLinkerMangled() [1/2]

Expected< JITEvaluatedSymbol > llvm::orc::LLJIT::lookupLinkerMangled ( JITDylib JD,
StringRef  Name 
)

Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead).

Definition at line 77 of file LLJIT.cpp.

Referenced by addObjectFile(), lookup(), and lookupLinkerMangled().

◆ lookupLinkerMangled() [2/2]

Expected<JITEvaluatedSymbol> llvm::orc::LLJIT::lookupLinkerMangled ( StringRef  Name)
inline

Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based on their IR name use the lookup function instead).

Definition at line 86 of file LLJIT.h.

References lookupLinkerMangled(), and Main.

◆ mangle()

std::string llvm::orc::LLJIT::mangle ( StringRef  UnmangledName)
protected

Definition at line 120 of file LLJIT.cpp.

References DL, and llvm::Mangler::getNameWithPrefix().

Referenced by getObjLinkingLayer(), and lookup().

◆ recordCtorDtors()

void llvm::orc::LLJIT::recordCtorDtors ( Module M)
protected

◆ runConstructors()

Error llvm::orc::LLJIT::runConstructors ( )
inline

Runs all not-yet-run static constructors.

Definition at line 101 of file LLJIT.h.

References CtorRunner, and llvm::orc::CtorDtorRunner::run().

◆ runDestructors()

Error llvm::orc::LLJIT::runDestructors ( )
inline

Runs all not-yet-run static destructors.

Definition at line 104 of file LLJIT.h.

References DtorRunner, and llvm::orc::CtorDtorRunner::run().

Member Data Documentation

◆ CompileLayer

IRCompileLayer llvm::orc::LLJIT::CompileLayer
protected

Definition at line 132 of file LLJIT.h.

Referenced by LLJIT().

◆ CompileThreads

std::unique_ptr<ThreadPool> llvm::orc::LLJIT::CompileThreads
protected

Definition at line 129 of file LLJIT.h.

Referenced by LLJIT().

◆ CtorRunner

CtorDtorRunner llvm::orc::LLJIT::CtorRunner
protected

Definition at line 134 of file LLJIT.h.

Referenced by LLJIT(), recordCtorDtors(), and runConstructors().

◆ DL

DataLayout llvm::orc::LLJIT::DL
protected

Definition at line 128 of file LLJIT.h.

Referenced by applyDataLayout(), and mangle().

◆ DtorRunner

CtorDtorRunner llvm::orc::LLJIT::DtorRunner
protected

Definition at line 134 of file LLJIT.h.

Referenced by LLJIT(), recordCtorDtors(), and runDestructors().

◆ ES

std::unique_ptr<ExecutionSession> llvm::orc::LLJIT::ES
protected

◆ Main

JITDylib& llvm::orc::LLJIT::Main
protected

◆ ObjLinkingLayer

RTDyldObjectLinkingLayer llvm::orc::LLJIT::ObjLinkingLayer
protected

Definition at line 131 of file LLJIT.h.

Referenced by getObjLinkingLayer(), and LLJIT().


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