LLVM 22.0.0git
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:
[legend]

Classes

class  PlatformSupport
 Initializer support for LLJIT. More...

Public Member Functions

virtual ~LLJIT ()
 Destruct this instance.
ExecutionSessiongetExecutionSession ()
 Returns the ExecutionSession for this instance.
const TriplegetTargetTriple () const
 Returns a reference to the triple for this instance.
const DataLayoutgetDataLayout () const
 Returns a reference to the DataLayout for this instance.
JITDylibgetMainJITDylib ()
 Returns a reference to the JITDylib representing the JIT'd main program.
JITDylibSP getProcessSymbolsJITDylib ()
 Returns the ProcessSymbols JITDylib, which by default reflects non-JIT'd symbols in the host process.
JITDylibSP getPlatformJITDylib ()
 Returns the Platform JITDylib, which will contain the ORC runtime (if given) and any platform symbols.
JITDylibgetJITDylibByName (StringRef Name)
 Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.
Expected< JITDylib & > loadPlatformDynamicLibrary (const char *Path)
 Load a (real) dynamic library and make its symbols available through a new JITDylib with the same name.
Error linkStaticLibraryInto (JITDylib &JD, std::unique_ptr< MemoryBuffer > LibBuffer)
 Link a static library into the given JITDylib.
Error linkStaticLibraryInto (JITDylib &JD, const char *Path)
 Link a static library into the given JITDylib.
Expected< JITDylib & > createJITDylib (std::string Name)
 Create a new JITDylib with the given name and return a reference to it.
JITDylibSearchOrder defaultLinkOrder ()
 Returns the default link order for this LLJIT instance.
Error addIRModule (ResourceTrackerSP RT, ThreadSafeModule TSM)
 Adds an IR module with the given ResourceTracker.
Error addIRModule (JITDylib &JD, ThreadSafeModule TSM)
 Adds an IR module to the given JITDylib.
Error addIRModule (ThreadSafeModule TSM)
 Adds an IR module to the Main JITDylib.
Error addObjectFile (ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib.
Error addObjectFile (JITDylib &JD, std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib.
Error addObjectFile (std::unique_ptr< MemoryBuffer > Obj)
 Adds an object file to the given JITDylib.
Expected< ExecutorAddrlookupLinkerMangled (JITDylib &JD, SymbolStringPtr 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).
Expected< ExecutorAddrlookupLinkerMangled (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).
Expected< ExecutorAddrlookupLinkerMangled (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).
Expected< ExecutorAddrlookup (JITDylib &JD, StringRef UnmangledName)
 Look up a symbol in JITDylib JD based on its IR symbol name.
Expected< ExecutorAddrlookup (StringRef UnmangledName)
 Look up a symbol in the main JITDylib based on its IR symbol name.
void setPlatformSupport (std::unique_ptr< PlatformSupport > PS)
 Set the PlatformSupport instance.
PlatformSupportgetPlatformSupport ()
 Get the PlatformSupport instance.
Error initialize (JITDylib &JD)
 Run the initializers for the given JITDylib.
Error deinitialize (JITDylib &JD)
 Run the deinitializers for the given JITDylib.
ObjectLayergetObjLinkingLayer ()
 Returns a reference to the ObjLinkingLayer.
ObjectTransformLayergetObjTransformLayer ()
 Returns a reference to the object transform layer.
IRTransformLayergetIRTransformLayer ()
 Returns a reference to the IR transform layer.
IRCompileLayergetIRCompileLayer ()
 Returns a reference to the IR compile layer.
std::string mangle (StringRef UnmangledName) const
 Returns a linker-mangled version of UnmangledName.
SymbolStringPtr mangleAndIntern (StringRef UnmangledName) const
 Returns an interned, linker-mangled version of UnmangledName.

Protected Member Functions

 LLJIT (LLJITBuilderState &S, Error &Err)
 Create an LLJIT instance with a single compile thread.
Error applyDataLayout (Module &M)

Static Protected Member Functions

static Expected< std::unique_ptr< ObjectLayer > > createObjectLinkingLayer (LLJITBuilderState &S, ExecutionSession &ES)
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction (LLJITBuilderState &S, JITTargetMachineBuilder JTMB)

Protected Attributes

std::unique_ptr< ExecutionSessionES
std::unique_ptr< PlatformSupportPS
JITDylibProcessSymbols = nullptr
JITDylibPlatform = nullptr
JITDylibMain = nullptr
JITDylibSearchOrder DefaultLinks
DataLayout DL
Triple TT
std::unique_ptr< ObjectLayerObjLinkingLayer
std::unique_ptr< ObjectTransformLayerObjTransformLayer
std::unique_ptr< IRCompileLayerCompileLayer
std::unique_ptr< IRTransformLayerTransformLayer
std::unique_ptr< IRTransformLayerInitHelperTransformLayer

Friends

template<typename, typename, typename>
class LLJITBuilderSetters
LLVM_ABI friend Expected< JITDylibSPsetUpGenericLLVMIRPlatform (LLJIT &J)
 Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables and (if present) build initialization and deinitialization functions.

Detailed Description

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

Create instances using LLJITBuilder.

Definition at line 42 of file LLJIT.h.

Constructor & Destructor Documentation

◆ ~LLJIT()

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

Destruct this instance.

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

Definition at line 860 of file LLJIT.cpp.

References ES.

◆ LLJIT()

Member Function Documentation

◆ addIRModule() [1/3]

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

Adds an IR module to the given JITDylib.

Definition at line 923 of file LLJIT.cpp.

References addIRModule(), and llvm::orc::JITDylib::getDefaultResourceTracker().

◆ addIRModule() [2/3]

Error llvm::orc::LLJIT::addIRModule ( ResourceTrackerSP RT,
ThreadSafeModule TSM )

Adds an IR module with the given ResourceTracker.

Definition at line 913 of file LLJIT.cpp.

References assert(), InitHelperTransformLayer, and llvm::orc::ThreadSafeModule::withModuleDo().

Referenced by addIRModule(), and addIRModule().

◆ addIRModule() [3/3]

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

Adds an IR module to the Main JITDylib.

Definition at line 144 of file LLJIT.h.

References addIRModule(), and Main.

◆ addObjectFile() [1/3]

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

Adds an object file to the given JITDylib.

Definition at line 934 of file LLJIT.cpp.

References addObjectFile(), and llvm::orc::JITDylib::getDefaultResourceTracker().

◆ addObjectFile() [2/3]

Error llvm::orc::LLJIT::addObjectFile ( ResourceTrackerSP RT,
std::unique_ptr< MemoryBuffer > Obj )

Adds an object file to the given JITDylib.

Definition at line 927 of file LLJIT.cpp.

References assert(), and ObjTransformLayer.

Referenced by addObjectFile(), and addObjectFile().

◆ addObjectFile() [3/3]

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

Adds an object file to the given JITDylib.

Definition at line 155 of file LLJIT.h.

References addObjectFile(), and Main.

◆ applyDataLayout()

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

◆ createCompileFunction()

Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > llvm::orc::LLJIT::createCompileFunction ( LLJITBuilderState & S,
JITTargetMachineBuilder JTMB )
staticprotected

If there is a custom compile function creator set then use it.

Definition at line 980 of file LLJIT.cpp.

References llvm::orc::LLJITBuilderState::CreateCompileFunction, llvm::orc::JITTargetMachineBuilder::createTargetMachine(), and llvm::orc::LLJITBuilderState::SupportConcurrentCompilation.

Referenced by LLJIT().

◆ createJITDylib()

Expected< JITDylib & > llvm::orc::LLJIT::createJITDylib ( std::string Name)

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

JITDylib names must be unique. If the given name is derived from user input or elsewhere in the environment then the client should check (e.g. by calling getJITDylibByName) that the given name is not already in use.

Definition at line 869 of file LLJIT.cpp.

References llvm::orc::JITDylib::addToLinkOrder(), DefaultLinks, and ES.

Referenced by LLJIT().

◆ createObjectLinkingLayer()

Expected< std::unique_ptr< ObjectLayer > > llvm::orc::LLJIT::createObjectLinkingLayer ( LLJITBuilderState & S,
ExecutionSession & ES )
staticprotected

◆ defaultLinkOrder()

JITDylibSearchOrder llvm::orc::LLJIT::defaultLinkOrder ( )
inline

Returns the default link order for this LLJIT instance.

This link order will be appended to the link order of JITDylibs created by LLJIT's createJITDylib method.

Definition at line 135 of file LLJIT.h.

References DefaultLinks.

◆ deinitialize()

Error llvm::orc::LLJIT::deinitialize ( JITDylib & JD)
inline

Run the deinitializers for the given JITDylib.

Definition at line 207 of file LLJIT.h.

References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::jitlink::JITLinkDylib::getName(), and PS.

◆ getDataLayout()

const DataLayout & llvm::orc::LLJIT::getDataLayout ( ) const
inline

Returns a reference to the DataLayout for this instance.

Definition at line 73 of file LLJIT.h.

References DL.

◆ getExecutionSession()

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

Returns the ExecutionSession for this instance.

Definition at line 67 of file LLJIT.h.

References ES.

Referenced by llvm::orc::enableDebuggerSupport(), llvm::orc::ExecutorNativePlatform::operator()(), and setUpGenericLLVMIRPlatform.

◆ getIRCompileLayer()

IRCompileLayer & llvm::orc::LLJIT::getIRCompileLayer ( )
inline

Returns a reference to the IR compile layer.

Definition at line 226 of file LLJIT.h.

References CompileLayer.

◆ getIRTransformLayer()

IRTransformLayer & llvm::orc::LLJIT::getIRTransformLayer ( )
inline

Returns a reference to the IR transform layer.

Definition at line 223 of file LLJIT.h.

References TransformLayer.

◆ getJITDylibByName()

JITDylib * llvm::orc::LLJIT::getJITDylibByName ( StringRef Name)
inline

Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.

Definition at line 94 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 76 of file LLJIT.h.

References Main.

◆ getObjLinkingLayer()

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

Returns a reference to the ObjLinkingLayer.

Definition at line 217 of file LLJIT.h.

References ObjLinkingLayer.

Referenced by llvm::orc::enableDebuggerSupport(), llvm::orc::ExecutorNativePlatform::operator()(), and setUpGenericLLVMIRPlatform.

◆ getObjTransformLayer()

ObjectTransformLayer & llvm::orc::LLJIT::getObjTransformLayer ( )
inline

Returns a reference to the object transform layer.

Definition at line 220 of file LLJIT.h.

References ObjTransformLayer.

◆ getPlatformJITDylib()

JITDylibSP llvm::orc::LLJIT::getPlatformJITDylib ( )

Returns the Platform JITDylib, which will contain the ORC runtime (if given) and any platform symbols.

Note: JIT'd code should not be added to the Platform JITDylib. Use the main JITDylib or a custom JITDylib instead.

Definition at line 867 of file LLJIT.cpp.

References Platform.

◆ getPlatformSupport()

PlatformSupport * llvm::orc::LLJIT::getPlatformSupport ( )
inline

Get the PlatformSupport instance.

Definition at line 194 of file LLJIT.h.

References PS.

◆ getProcessSymbolsJITDylib()

JITDylibSP llvm::orc::LLJIT::getProcessSymbolsJITDylib ( )

Returns the ProcessSymbols JITDylib, which by default reflects non-JIT'd symbols in the host process.

Note: JIT'd code should not be added to the ProcessSymbols JITDylib. Use the main JITDylib or a custom JITDylib instead.

Definition at line 865 of file LLJIT.cpp.

References ProcessSymbols.

Referenced by llvm::orc::enableDebuggerSupport(), llvm::orc::ExecutorNativePlatform::operator()(), and setUpGenericLLVMIRPlatform.

◆ getTargetTriple()

const Triple & llvm::orc::LLJIT::getTargetTriple ( ) const
inline

Returns a reference to the triple for this instance.

Definition at line 70 of file LLJIT.h.

References TT.

Referenced by llvm::orc::enableDebuggerSupport(), LLJIT(), llvm::orc::ExecutorNativePlatform::operator()(), and setUpGenericLLVMIRPlatform.

◆ initialize()

Error llvm::orc::LLJIT::initialize ( JITDylib & JD)
inline

Run the initializers for the given JITDylib.

Definition at line 197 of file LLJIT.h.

References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::jitlink::JITLinkDylib::getName(), and PS.

◆ linkStaticLibraryInto() [1/2]

Error llvm::orc::LLJIT::linkStaticLibraryInto ( JITDylib & JD,
const char * Path )

Link a static library into the given JITDylib.

If the given host path contains a valid static archive (or a universal binary with an archive slice that fits the LLJIT instance's platform / architecture) then it will be added to the given JITDylib using a StaticLibraryDefinitionGenerator.

Definition at line 903 of file LLJIT.cpp.

References llvm::orc::JITDylib::addGenerator(), G, llvm::orc::StaticLibraryDefinitionGenerator::Load(), ObjLinkingLayer, and llvm::Error::success().

◆ linkStaticLibraryInto() [2/2]

Error llvm::orc::LLJIT::linkStaticLibraryInto ( JITDylib & JD,
std::unique_ptr< MemoryBuffer > LibBuffer )

Link a static library into the given JITDylib.

If the given MemoryBuffer contains a valid static archive (or a universal binary with an archive slice that fits the LLJIT instance's platform / architecture) then it will be added to the given JITDylib using a StaticLibraryDefinitionGenerator.

Definition at line 891 of file LLJIT.cpp.

References llvm::orc::JITDylib::addGenerator(), llvm::orc::StaticLibraryDefinitionGenerator::Create(), G, ObjLinkingLayer, and llvm::Error::success().

◆ loadPlatformDynamicLibrary()

Expected< JITDylib & > llvm::orc::LLJIT::loadPlatformDynamicLibrary ( const char * Path)

Load a (real) dynamic library and make its symbols available through a new JITDylib with the same name.

If the given executor path contains a valid platform dynamic library then that library will be loaded, and a new bare JITDylib whose name is the given path will be created to make the library's symbols available to JIT'd code.

Definition at line 878 of file LLJIT.cpp.

References llvm::orc::JITDylib::addGenerator(), ES, G, and llvm::orc::EPCDynamicLibrarySearchGenerator::Load().

◆ lookup() [1/2]

Expected< ExecutorAddr > 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 179 of file LLJIT.h.

References lookupLinkerMangled(), and mangle().

◆ lookup() [2/2]

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

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

Definition at line 184 of file LLJIT.h.

References lookup(), and Main.

◆ lookupLinkerMangled() [1/3]

Expected< ExecutorAddr > llvm::orc::LLJIT::lookupLinkerMangled ( JITDylib & JD,
StringRef Name )
inline

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 166 of file LLJIT.h.

References ES, and lookupLinkerMangled().

◆ lookupLinkerMangled() [2/3]

Expected< ExecutorAddr > llvm::orc::LLJIT::lookupLinkerMangled ( JITDylib & JD,
SymbolStringPtr 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 938 of file LLJIT.cpp.

References ES, llvm::orc::makeJITDylibSearchOrder(), llvm::orc::MatchAllSymbols, and llvm::Expected< T >::takeError().

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

◆ lookupLinkerMangled() [3/3]

Expected< ExecutorAddr > 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 174 of file LLJIT.h.

References lookupLinkerMangled(), and Main.

◆ mangle()

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

Returns a linker-mangled version of UnmangledName.

Definition at line 1081 of file LLJIT.cpp.

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

Referenced by lookup(), and mangleAndIntern().

◆ mangleAndIntern()

SymbolStringPtr llvm::orc::LLJIT::mangleAndIntern ( StringRef UnmangledName) const
inline

Returns an interned, linker-mangled version of UnmangledName.

Definition at line 232 of file LLJIT.h.

References ES, and mangle().

◆ setPlatformSupport()

void llvm::orc::LLJIT::setPlatformSupport ( std::unique_ptr< PlatformSupport > PS)
inline

◆ LLJITBuilderSetters

template<typename, typename, typename>
friend class LLJITBuilderSetters
friend

Definition at line 43 of file LLJIT.h.

References LLJIT(), LLJITBuilderSetters, LLVM_ABI, and setUpGenericLLVMIRPlatform.

Referenced by LLJITBuilderSetters.

◆ setUpGenericLLVMIRPlatform

LLVM_ABI friend Expected< JITDylibSP > setUpGenericLLVMIRPlatform ( LLJIT & J)
friend

Member Data Documentation

◆ CompileLayer

std::unique_ptr<IRCompileLayer> llvm::orc::LLJIT::CompileLayer
protected

Definition at line 262 of file LLJIT.h.

Referenced by getIRCompileLayer(), and LLJIT().

◆ DefaultLinks

JITDylibSearchOrder llvm::orc::LLJIT::DefaultLinks
protected

Definition at line 255 of file LLJIT.h.

Referenced by createJITDylib(), defaultLinkOrder(), and LLJIT().

◆ DL

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

Definition at line 257 of file LLJIT.h.

Referenced by applyDataLayout(), getDataLayout(), LLJIT(), and mangle().

◆ ES

◆ InitHelperTransformLayer

std::unique_ptr<IRTransformLayer> llvm::orc::LLJIT::InitHelperTransformLayer
protected

◆ Main

JITDylib* llvm::orc::LLJIT::Main = nullptr
protected

◆ ObjLinkingLayer

std::unique_ptr<ObjectLayer> llvm::orc::LLJIT::ObjLinkingLayer
protected

Definition at line 260 of file LLJIT.h.

Referenced by getObjLinkingLayer(), linkStaticLibraryInto(), linkStaticLibraryInto(), and LLJIT().

◆ ObjTransformLayer

std::unique_ptr<ObjectTransformLayer> llvm::orc::LLJIT::ObjTransformLayer
protected

Definition at line 261 of file LLJIT.h.

Referenced by addObjectFile(), getObjTransformLayer(), and LLJIT().

◆ Platform

JITDylib* llvm::orc::LLJIT::Platform = nullptr
protected

Definition at line 252 of file LLJIT.h.

Referenced by getPlatformJITDylib(), and LLJIT().

◆ ProcessSymbols

JITDylib* llvm::orc::LLJIT::ProcessSymbols = nullptr
protected

Definition at line 251 of file LLJIT.h.

Referenced by getProcessSymbolsJITDylib(), and LLJIT().

◆ PS

std::unique_ptr<PlatformSupport> llvm::orc::LLJIT::PS
protected

Definition at line 249 of file LLJIT.h.

Referenced by deinitialize(), getPlatformSupport(), initialize(), and setPlatformSupport().

◆ TransformLayer

std::unique_ptr<IRTransformLayer> llvm::orc::LLJIT::TransformLayer
protected

Definition at line 263 of file LLJIT.h.

Referenced by getIRTransformLayer(), and LLJIT().

◆ TT

Triple llvm::orc::LLJIT::TT
protected

Definition at line 258 of file LLJIT.h.

Referenced by getTargetTriple(), and LLJIT().


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