LLVM 22.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) |
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 |
LLVM_ABI friend 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 998 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 923 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 913 of file LLJIT.cpp.
References assert(), InitHelperTransformLayer, and llvm::orc::ThreadSafeModule::withModuleDo().
Referenced by addIRModule().
|
inline |
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().
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().
|
inline |
Definition at line 1090 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 980 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 869 of file LLJIT.cpp.
References llvm::orc::JITDylib::addToLinkOrder(), DefaultLinks, ES, and Name.
Referenced by LLJIT().
|
staticprotected |
Definition at line 949 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 |
Run the deinitializers for the given JITDylib.
Definition at line 207 of file LLJIT.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, and llvm::jitlink::JITLinkDylib::getName().
|
inline |
Returns a reference to the DataLayout for this instance.
Definition at line 73 of file LLJIT.h.
References DL.
|
inline |
Returns the ExecutionSession for this instance.
Definition at line 67 of file LLJIT.h.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), llvm::orc::enableDebuggerSupport(), llvm::orc::ORCPlatformSupport::initialize(), and llvm::orc::ExecutorNativePlatform::operator()().
|
inline |
|
inline |
|
inline |
Returns a reference to the JITDylib representing the JIT'd main program.
Definition at line 76 of file LLJIT.h.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), and llvm::orc::ORCPlatformSupport::initialize().
|
inline |
Returns a reference to the ObjLinkingLayer.
Definition at line 217 of file LLJIT.h.
Referenced by llvm::orc::enableDebuggerSupport(), and llvm::orc::ExecutorNativePlatform::operator()().
|
inline |
JITDylibSP llvm::orc::LLJIT::getPlatformJITDylib | ( | ) |
|
inline |
Get the PlatformSupport instance.
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(), and llvm::orc::ExecutorNativePlatform::operator()().
Returns a reference to the triple for this instance.
Definition at line 70 of file LLJIT.h.
Referenced by llvm::orc::enableDebuggerSupport(), and llvm::orc::ExecutorNativePlatform::operator()().
Run the initializers for the given JITDylib.
Definition at line 197 of file LLJIT.h.
References assert(), llvm::dbgs(), DEBUG_WITH_TYPE, and llvm::jitlink::JITLinkDylib::getName().
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().
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().
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().
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 938 of file LLJIT.cpp.
References ES, llvm::orc::makeJITDylibSearchOrder(), llvm::orc::MatchAllSymbols, Name, and Sym.
|
inline |
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().
|
inline |
Returns an interned, linker-mangled version of UnmangledName.
Definition at line 232 of file LLJIT.h.
Referenced by llvm::orc::ORCPlatformSupport::deinitialize(), and llvm::orc::ORCPlatformSupport::initialize().
|
inline |
Set the PlatformSupport instance.
Definition at line 189 of file LLJIT.h.
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 1211 of file LLJIT.cpp.
Referenced by LLJIT().
|
protected |
|
protected |
Definition at line 255 of file LLJIT.h.
Referenced by createJITDylib(), and LLJIT().
|
protected |
Definition at line 257 of file LLJIT.h.
Referenced by applyDataLayout(), mangle(), and llvm::orc::LLJITBuilderState::prepareForConstruction().
|
protected |
Definition at line 248 of file LLJIT.h.
Referenced by createJITDylib(), createObjectLinkingLayer(), LLJIT(), loadPlatformDynamicLibrary(), lookupLinkerMangled(), llvm::orc::LLJITBuilderState::prepareForConstruction(), and ~LLJIT().
|
protected |
Definition at line 264 of file LLJIT.h.
Referenced by addIRModule(), LLJIT(), and llvm::orc::LLJIT::PlatformSupport::setInitTransform().
|
protected |
Definition at line 253 of file LLJIT.h.
Referenced by llvm::orc::LLLazyJIT::addLazyIRModule(), and LLJIT().
|
protected |
Definition at line 260 of file LLJIT.h.
Referenced by linkStaticLibraryInto(), and LLJIT().
|
protected |
Definition at line 261 of file LLJIT.h.
Referenced by addObjectFile(), and LLJIT().
|
protected |
Definition at line 252 of file LLJIT.h.
Referenced by getPlatformJITDylib(), and LLJIT().
|
protected |
Definition at line 251 of file LLJIT.h.
Referenced by getProcessSymbolsJITDylib(), and LLJIT().
|
protected |
|
protected |
|
protected |
Definition at line 258 of file LLJIT.h.
Referenced by llvm::orc::LLJITBuilderState::prepareForConstruction().