Skip to content

Commit b0818df

Browse files
committed
[ORC][LLJIT] Add a Pre-PlatformSetup-Setup function.
This function will be run prior to platform setup to provide LLJIT clients with a chance to customize the LLJIT instance (e.g. install plugins) before the JIT runtime is loaded. The motivating use-case is debugger support: We want to install the debugger plugin before the runtime is loaded (during platform setup) so that the runtime itself can be debugged. A patch to do this will be committed shortly.
1 parent 836411b commit b0818df

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ class LLJITBuilderState {
319319
ProcessSymbolsJITDylibSetupFunction SetupProcessSymbolsJITDylib;
320320
ObjectLinkingLayerCreator CreateObjectLinkingLayer;
321321
CompileFunctionCreator CreateCompileFunction;
322+
unique_function<Error(LLJIT &)> PrePlatformSetup;
322323
PlatformSetupFunction SetUpPlatform;
323324
unsigned NumCompileThreads = 0;
324325
bool EnableDebuggerSupport = false;
@@ -418,6 +419,19 @@ class LLJITBuilderSetters {
418419
return impl();
419420
}
420421

422+
/// Set a setup function to be run just before the PlatformSetupFunction is
423+
/// run.
424+
///
425+
/// This can be used to customize the LLJIT instance before the platform is
426+
/// set up. E.g. By installing a debugger support plugin before the platform
427+
/// is set up (when the ORC runtime is loaded) we enable debugging of the
428+
/// runtime itself.
429+
SetterImpl &
430+
setPrePlatformSetup(unique_function<Error(LLJIT &)> PrePlatformSetup) {
431+
impl().PrePlatformSetup = std::move(PrePlatformSetup);
432+
return impl();
433+
}
434+
421435
/// Set up an PlatformSetupFunction.
422436
///
423437
/// If this method is not called then setUpGenericLLVMIRPlatform

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,13 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
10541054
}
10551055
}
10561056

1057+
if (S.PrePlatformSetup) {
1058+
if (auto Err2 = S.PrePlatformSetup(*this)) {
1059+
Err = std::move(Err2);
1060+
return;
1061+
}
1062+
}
1063+
10571064
if (!S.SetUpPlatform)
10581065
S.SetUpPlatform = setUpGenericLLVMIRPlatform;
10591066

0 commit comments

Comments
 (0)