LLVM 20.0.0git
|
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT. More...
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
Classes | |
class | PlatformSupport |
Initializer support for LLJIT. More... | |
Public Member Functions | |
virtual | ~LLJIT () |
Destruct this instance. | |
ExecutionSession & | getExecutionSession () |
Returns the ExecutionSession for this instance. | |
const Triple & | getTargetTriple () const |
Returns a reference to the triple for this instance. | |
const DataLayout & | getDataLayout () const |
Returns a reference to the DataLayout for this instance. | |
JITDylib & | getMainJITDylib () |
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. | |
JITDylib * | getJITDylibByName (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< ExecutorAddr > | 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). | |
Expected< ExecutorAddr > | 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). | |
Expected< ExecutorAddr > | lookupLinkerMangled (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< ExecutorAddr > | lookup (JITDylib &JD, StringRef UnmangledName) |
Look up a symbol in JITDylib JD based on its IR symbol name. | |
Expected< ExecutorAddr > | lookup (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. | |
PlatformSupport * | getPlatformSupport () |
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. | |
ObjectLayer & | getObjLinkingLayer () |
Returns a reference to the ObjLinkingLayer. | |
ObjectTransformLayer & | getObjTransformLayer () |
Returns a reference to the object transform layer. | |
IRTransformLayer & | getIRTransformLayer () |
Returns a reference to the IR transform layer. | |
IRCompileLayer & | getIRCompileLayer () |
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) |
void | recordCtorDtors (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< ExecutionSession > | ES |
std::unique_ptr< PlatformSupport > | PS |
JITDylib * | ProcessSymbols = nullptr |
JITDylib * | Platform = nullptr |
JITDylib * | Main = nullptr |
JITDylibSearchOrder | DefaultLinks |
DataLayout | DL |
Triple | TT |
std::unique_ptr< ObjectLayer > | ObjLinkingLayer |
std::unique_ptr< ObjectTransformLayer > | ObjTransformLayer |
std::unique_ptr< IRCompileLayer > | CompileLayer |
std::unique_ptr< IRTransformLayer > | TransformLayer |
std::unique_ptr< IRTransformLayer > | InitHelperTransformLayer |
Friends | |
template<typename , typename , typename > | |
class | LLJITBuilderSetters |
Expected< JITDylibSP > | setUpGenericLLVMIRPlatform (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. | |
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
Create instances using LLJITBuilder.
|
virtual |
|
protected |
Create an LLJIT instance with a single compile thread.
Definition at line 977 of file LLJIT.cpp.
References _, assert(), CompileLayer, llvm::orc::SelfExecutorProcessControl::Create(), createCompileFunction(), createJITDylib(), createObjectLinkingLayer(), DefaultLinks, llvm::orc::LLJITBuilderState::EPC, ES, llvm::orc::LLJITBuilderState::ES, InitHelperTransformLayer, llvm::orc::LLJITBuilderState::JTMB, llvm::orc::LLJITBuilderState::LinkProcessSymbolsByDefault, Main, llvm::orc::MatchExportedSymbolsOnly, ObjLinkingLayer, ObjTransformLayer, Platform, llvm::orc::LLJITBuilderState::PrePlatformSetup, ProcessSymbols, setUpGenericLLVMIRPlatform, llvm::orc::LLJITBuilderState::SetUpPlatform, llvm::orc::LLJITBuilderState::SetupProcessSymbolsJITDylib, llvm::orc::LLJITBuilderState::SupportConcurrentCompilation, and TransformLayer.
Error llvm::orc::LLJIT::addIRModule | ( | JITDylib & | JD, |
ThreadSafeModule | TSM | ||
) |
Adds an IR module to the given JITDylib.
Definition at line 904 of file LLJIT.cpp.
References addIRModule(), and llvm::orc::JITDylib::getDefaultResourceTracker().
Error llvm::orc::LLJIT::addIRModule | ( | ResourceTrackerSP | RT, |
ThreadSafeModule | TSM | ||
) |
Adds an IR module with the given ResourceTracker.
Definition at line 894 of file LLJIT.cpp.
References assert(), InitHelperTransformLayer, and llvm::orc::ThreadSafeModule::withModuleDo().
Referenced by addIRModule().
|
inline |
Adds an IR module to the Main JITDylib.
Definition at line 140 of file LLJIT.h.
References addIRModule(), and Main.
Error llvm::orc::LLJIT::addObjectFile | ( | JITDylib & | JD, |
std::unique_ptr< MemoryBuffer > | Obj | ||
) |
Adds an object file to the given JITDylib.
Definition at line 915 of file LLJIT.cpp.
References addObjectFile(), and llvm::orc::JITDylib::getDefaultResourceTracker().
Error llvm::orc::LLJIT::addObjectFile | ( | ResourceTrackerSP | RT, |
std::unique_ptr< MemoryBuffer > | Obj | ||
) |
Adds an object file to the given JITDylib.
Definition at line 908 of file LLJIT.cpp.
References assert(), and ObjTransformLayer.
Referenced by addObjectFile().
|
inline |
Adds an object file to the given JITDylib.
Definition at line 151 of file LLJIT.h.
References addObjectFile(), and Main.
Definition at line 1072 of file LLJIT.cpp.
References DL, llvm::DataLayout::getStringRepresentation(), llvm::inconvertibleErrorCode(), and llvm::Error::success().
|
staticprotected |
If there is a custom compile function creator set then use it.
Definition at line 959 of file LLJIT.cpp.
References llvm::orc::LLJITBuilderState::CreateCompileFunction, llvm::orc::JITTargetMachineBuilder::createTargetMachine(), and llvm::orc::LLJITBuilderState::SupportConcurrentCompilation.
Referenced by LLJIT().
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 850 of file LLJIT.cpp.
References llvm::orc::JITDylib::addToLinkOrder(), DefaultLinks, ES, and Name.
Referenced by LLJIT().
|
staticprotected |
Definition at line 930 of file LLJIT.cpp.
References llvm::orc::LLJITBuilderState::CreateObjectLinkingLayer, ES, llvm::orc::LLJITBuilderState::JTMB, llvm::Triple::ppc64, and llvm::Triple::ppc64le.
Referenced by LLJIT().
|
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 131 of file LLJIT.h.
References DefaultLinks.
Run the deinitializers for the given JITDylib.
Definition at line 203 of file LLJIT.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::jitlink::JITLinkDylib::getName(), and PS.
|
inline |
Returns a reference to the DataLayout for this instance.
Definition at line 69 of file LLJIT.h.
References DL.
|
inline |
Returns the ExecutionSession for this instance.
Definition at line 63 of file LLJIT.h.
References ES.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), llvm::orc::enableDebuggerSupport(), llvm::orc::ORCPlatformSupport::initialize(), and llvm::orc::ExecutorNativePlatform::operator()().
|
inline |
Returns a reference to the IR compile layer.
Definition at line 222 of file LLJIT.h.
References CompileLayer.
|
inline |
Returns a reference to the IR transform layer.
Definition at line 219 of file LLJIT.h.
References TransformLayer.
|
inline |
Returns a reference to the JITDylib representing the JIT'd main program.
Definition at line 72 of file LLJIT.h.
References Main.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), and llvm::orc::ORCPlatformSupport::initialize().
|
inline |
Returns a reference to the ObjLinkingLayer.
Definition at line 213 of file LLJIT.h.
References ObjLinkingLayer.
Referenced by llvm::orc::enableDebuggerSupport(), and llvm::orc::ExecutorNativePlatform::operator()().
|
inline |
Returns a reference to the object transform layer.
Definition at line 216 of file LLJIT.h.
References ObjTransformLayer.
JITDylibSP llvm::orc::LLJIT::getPlatformJITDylib | ( | ) |
|
inline |
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 846 of file LLJIT.cpp.
References ProcessSymbols.
Referenced by llvm::orc::enableDebuggerSupport(), and llvm::orc::ExecutorNativePlatform::operator()().
Returns a reference to the triple for this instance.
Definition at line 66 of file LLJIT.h.
References TT.
Referenced by llvm::orc::enableDebuggerSupport(), and llvm::orc::ExecutorNativePlatform::operator()().
Run the initializers for the given JITDylib.
Definition at line 193 of file LLJIT.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::jitlink::JITLinkDylib::getName(), and PS.
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 884 of file LLJIT.cpp.
References llvm::orc::JITDylib::addGenerator(), G, llvm::orc::StaticLibraryDefinitionGenerator::Load(), ObjLinkingLayer, and llvm::Error::success().
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 872 of file LLJIT.cpp.
References llvm::orc::JITDylib::addGenerator(), llvm::orc::StaticLibraryDefinitionGenerator::Create(), G, ObjLinkingLayer, and llvm::Error::success().
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 859 of file LLJIT.cpp.
References llvm::orc::JITDylib::addGenerator(), ES, G, and llvm::orc::EPCDynamicLibrarySearchGenerator::Load().
Referenced by llvm::orc::LoadAndLinkDynLibrary::operator()().
|
inline |
|
inline |
|
inline |
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 919 of file LLJIT.cpp.
References ES, llvm::orc::makeJITDylibSearchOrder(), llvm::orc::MatchAllSymbols, Name, and Sym.
Referenced by lookup(), and lookupLinkerMangled().
|
inline |
std::string llvm::orc::LLJIT::mangle | ( | StringRef | UnmangledName | ) | const |
Returns a linker-mangled version of UnmangledName.
Definition at line 1063 of file LLJIT.cpp.
References DL, and llvm::Mangler::getNameWithPrefix().
Referenced by lookup(), and mangleAndIntern().
|
inline |
Returns an interned, linker-mangled version of UnmangledName.
Definition at line 228 of file LLJIT.h.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), and llvm::orc::ORCPlatformSupport::initialize().
|
protected |
|
inline |
Set the PlatformSupport instance.
Definition at line 185 of file LLJIT.h.
References PS.
Referenced by llvm::orc::ExecutorNativePlatform::operator()(), llvm::orc::setUpInactivePlatform(), and llvm::orc::setUpOrcPlatformManually().
|
friend |
|
friend |
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables and (if present) build initialization and deinitialization functions.
Platform specific initialization configurations should be preferred where available.
Definition at line 1193 of file LLJIT.cpp.
Referenced by LLJIT().
|
protected |
Definition at line 260 of file LLJIT.h.
Referenced by getIRCompileLayer(), and LLJIT().
|
protected |
Definition at line 253 of file LLJIT.h.
Referenced by createJITDylib(), defaultLinkOrder(), and LLJIT().
|
protected |
Definition at line 255 of file LLJIT.h.
Referenced by applyDataLayout(), getDataLayout(), mangle(), and llvm::orc::LLJITBuilderState::prepareForConstruction().
|
protected |
Definition at line 246 of file LLJIT.h.
Referenced by createJITDylib(), createObjectLinkingLayer(), getExecutionSession(), getJITDylibByName(), LLJIT(), loadPlatformDynamicLibrary(), lookupLinkerMangled(), mangleAndIntern(), llvm::orc::LLJITBuilderState::prepareForConstruction(), and ~LLJIT().
|
protected |
Definition at line 262 of file LLJIT.h.
Referenced by addIRModule(), LLJIT(), and llvm::orc::LLJIT::PlatformSupport::setInitTransform().
|
protected |
Definition at line 251 of file LLJIT.h.
Referenced by addIRModule(), llvm::orc::LLLazyJIT::addLazyIRModule(), addObjectFile(), getMainJITDylib(), LLJIT(), lookup(), and lookupLinkerMangled().
|
protected |
Definition at line 258 of file LLJIT.h.
Referenced by getObjLinkingLayer(), linkStaticLibraryInto(), LLJIT(), and llvm::orc::LLJITBuilderState::prepareForConstruction().
|
protected |
Definition at line 259 of file LLJIT.h.
Referenced by addObjectFile(), getObjTransformLayer(), and LLJIT().
|
protected |
Definition at line 250 of file LLJIT.h.
Referenced by getPlatformJITDylib(), and LLJIT().
|
protected |
Definition at line 249 of file LLJIT.h.
Referenced by getProcessSymbolsJITDylib(), and LLJIT().
|
protected |
Definition at line 247 of file LLJIT.h.
Referenced by deinitialize(), getPlatformSupport(), initialize(), and setPlatformSupport().
|
protected |
Definition at line 261 of file LLJIT.h.
Referenced by getIRTransformLayer(), and LLJIT().
|
protected |
Definition at line 256 of file LLJIT.h.
Referenced by getTargetTriple(), and llvm::orc::LLJITBuilderState::prepareForConstruction().