diff options
author | Stefan Gränitz <stefan.graenitz@gmail.com> | 2024-03-07 23:05:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 23:05:46 +0100 |
commit | f78129e2bbafdd04a71bc09fc44e0797dd08db05 (patch) | |
tree | 1b9f55250dd1d5bda65b013c7e7be4d28ea6bba1 | |
parent | a0c7714525b696d90d2021249f9105c24ca7adcc (diff) | |
download | llvm-f78129e2bbafdd04a71bc09fc44e0797dd08db05.zip llvm-f78129e2bbafdd04a71bc09fc44e0797dd08db05.tar.gz llvm-f78129e2bbafdd04a71bc09fc44e0797dd08db05.tar.bz2 |
[Orc] Add NotifyCreated callback for LLJITBuilder (#84175)
This is useful to attach generators to JITDylibs or inject initial
symbol definitions.
-rw-r--r-- | llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h index 76d16e6..d5682fc 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h @@ -311,6 +311,8 @@ public: using PlatformSetupFunction = unique_function<Expected<JITDylibSP>(LLJIT &J)>; + using NotifyCreatedFunction = std::function<Error(LLJIT &)>; + std::unique_ptr<ExecutorProcessControl> EPC; std::unique_ptr<ExecutionSession> ES; std::optional<JITTargetMachineBuilder> JTMB; @@ -321,6 +323,7 @@ public: CompileFunctionCreator CreateCompileFunction; unique_function<Error(LLJIT &)> PrePlatformSetup; PlatformSetupFunction SetUpPlatform; + NotifyCreatedFunction NotifyCreated; unsigned NumCompileThreads = 0; /// Called prior to JIT class construcion to fix up defaults. @@ -441,6 +444,16 @@ public: return impl(); } + /// Set up a callback after successful construction of the JIT. + /// + /// This is useful to attach generators to JITDylibs or inject initial symbol + /// definitions. + SetterImpl & + setNotifyCreatedCallback(LLJITBuilderState::NotifyCreatedFunction Callback) { + impl().NotifyCreated = std::move(Callback); + return impl(); + } + /// Set the number of compile threads to use. /// /// If set to zero, compilation will be performed on the execution thread when @@ -474,6 +487,11 @@ public: std::unique_ptr<JITType> J(new JITType(impl(), Err)); if (Err) return std::move(Err); + + if (impl().NotifyCreated) + if (Error Err = impl().NotifyCreated(*J)) + return Err; + return std::move(J); } |