Skip to content

Commit 8211050

Browse files
committed
[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.
1 parent 6b6ea93 commit 8211050

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ class LLJITBuilderState {
307307
JITTargetMachineBuilder JTMB)>;
308308

309309
using ProcessSymbolsJITDylibSetupFunction =
310-
std::function<Error(JITDylib &JD)>;
310+
unique_function<Expected<JITDylibSP>(LLJIT &J)>;
311311

312312
using PlatformSetupFunction = unique_function<Expected<JITDylibSP>(LLJIT &J)>;
313313

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,13 +787,15 @@ Error LLJITBuilderState::prepareForConstruction() {
787787
dbgs() << ")\n";
788788
});
789789

790-
SetupProcessSymbolsJITDylib = [this](JITDylib &JD) -> Error {
790+
SetupProcessSymbolsJITDylib = [this](LLJIT &J) -> Expected<JITDylibSP> {
791+
auto &JD =
792+
J.getExecutionSession().createBareJITDylib("<Process Symbols>");
791793
auto G = orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(
792794
DL->getGlobalPrefix());
793795
if (!G)
794796
return G.takeError();
795797
JD.addGenerator(std::move(*G));
796-
return Error::success();
798+
return &JD;
797799
};
798800
}
799801

@@ -998,9 +1000,10 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
9981000
}
9991001

10001002
if (S.SetupProcessSymbolsJITDylib) {
1001-
ProcessSymbols = &ES->createBareJITDylib("<Process Symbols>");
1002-
if (auto Err2 = S.SetupProcessSymbolsJITDylib(*ProcessSymbols)) {
1003-
Err = std::move(Err2);
1003+
if (auto ProcSymsJD = S.SetupProcessSymbolsJITDylib(*this)) {
1004+
ProcessSymbols = ProcSymsJD->get();
1005+
} else {
1006+
Err = ProcSymsJD.takeError();
10041007
return;
10051008
}
10061009
}

0 commit comments

Comments
 (0)