[llvm] 8211050 - [LLJIT] Generalize LLJITBuilder::ProcessSymbolsJITDylibSetupFunction.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 22 19:20:11 PDT 2023
Author: Lang Hames
Date: 2023-08-22T19:15:28-07:00
New Revision: 8211050cb5fba8d4b1267f97c43ead2f2f2ef370
URL: https://github.com/llvm/llvm-project/commit/8211050cb5fba8d4b1267f97c43ead2f2f2ef370
DIFF: https://github.com/llvm/llvm-project/commit/8211050cb5fba8d4b1267f97c43ead2f2f2ef370.diff
LOG: [LLJIT] Generalize LLJITBuilder::ProcessSymbolsJITDylibSetupFunction.
For many interesting process-symbols setups we need access to the LLJIT instance
(e.g. to mangle symbols, or inspect the process triple). This patch updates the
ProcessSymbolsJITDylibSetupFunction to take an LLJIT reference and return the
process symbols JITDylib, which the callback must now create.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index d1affd9d2eb3cb..ab54e0c2c28820 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -307,7 +307,7 @@ class LLJITBuilderState {
JITTargetMachineBuilder JTMB)>;
using ProcessSymbolsJITDylibSetupFunction =
- std::function<Error(JITDylib &JD)>;
+ unique_function<Expected<JITDylibSP>(LLJIT &J)>;
using PlatformSetupFunction = unique_function<Expected<JITDylibSP>(LLJIT &J)>;
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 7c7c2f000368e2..b92c30dd6b722f 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -787,13 +787,15 @@ Error LLJITBuilderState::prepareForConstruction() {
dbgs() << ")\n";
});
- SetupProcessSymbolsJITDylib = [this](JITDylib &JD) -> Error {
+ SetupProcessSymbolsJITDylib = [this](LLJIT &J) -> Expected<JITDylibSP> {
+ auto &JD =
+ J.getExecutionSession().createBareJITDylib("<Process Symbols>");
auto G = orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(
DL->getGlobalPrefix());
if (!G)
return G.takeError();
JD.addGenerator(std::move(*G));
- return Error::success();
+ return &JD;
};
}
@@ -998,9 +1000,10 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
}
if (S.SetupProcessSymbolsJITDylib) {
- ProcessSymbols = &ES->createBareJITDylib("<Process Symbols>");
- if (auto Err2 = S.SetupProcessSymbolsJITDylib(*ProcessSymbols)) {
- Err = std::move(Err2);
+ if (auto ProcSymsJD = S.SetupProcessSymbolsJITDylib(*this)) {
+ ProcessSymbols = ProcSymsJD->get();
+ } else {
+ Err = ProcSymsJD.takeError();
return;
}
}
More information about the llvm-commits
mailing list