Skip to content

Commit

Permalink
Re-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." w…
Browse files Browse the repository at this point in the history
…ith fixes.

This reapplies 371cb1a, which was reverted in 0b2240e due to bot
failures.

The clang-repl test failure is fixed by dropping the process symbols definition
generator that was manually attached to the main JITDylib, since LLJIT now
exposes process symbols by default. (The bug was triggered when JIT'd code used
the process atexit provided by the generator, rather than the JIT atexit which
has been moved into the platform JITDylib).

Any LLJIT clients that see crashes in static destructors should likewise remove
any process symbol generators attached to their main JITDylib.
  • Loading branch information
lhames committed Apr 8, 2023
1 parent 7fff3bf commit 231107a
Show file tree
Hide file tree
Showing 13 changed files with 388 additions and 417 deletions.
9 changes: 0 additions & 9 deletions clang/lib/Interpreter/IncrementalExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
Err = JitOrErr.takeError();
return;
}

const char Pref = Jit->getDataLayout().getGlobalPrefix();
// Discover symbols from the process as a fallback.
if (auto PSGOrErr = DynamicLibrarySearchGenerator::GetForCurrentProcess(Pref))
Jit->getMainJITDylib().addGenerator(std::move(*PSGOrErr));
else {
Err = PSGOrErr.takeError();
return;
}
}

IncrementalExecutor::~IncrementalExecutor() {}
Expand Down
1 change: 0 additions & 1 deletion llvm/examples/OrcV2Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_subdirectory(OrcV2CBindingsBasicUsage)
add_subdirectory(OrcV2CBindingsDumpObjects)
add_subdirectory(OrcV2CBindingsIRTransforms)
add_subdirectory(OrcV2CBindingsMCJITLikeMemoryManager)
add_subdirectory(OrcV2CBindingsReflectProcessSymbols)
add_subdirectory(OrcV2CBindingsRemovableCode)
add_subdirectory(OrcV2CBindingsLazy)
add_subdirectory(OrcV2CBindingsVeryLazy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
#include "llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
Expand Down Expand Up @@ -152,9 +151,6 @@ int main(int argc, char *argv[]) {
EPCIU->createLazyCallThroughManager(
J->getExecutionSession(), ExecutorAddr::fromPtr(&reportErrorAndExit));
auto ISM = EPCIU->createIndirectStubsManager();
J->getMainJITDylib().addGenerator(
ExitOnErr(EPCDynamicLibrarySearchGenerator::GetForTargetProcess(
J->getExecutionSession())));

// (4) Add modules.
ExitOnErr(J->addIRModule(ExitOnErr(parseExampleModule(FooMod, "foo-mod"))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ int main(int argc, char *argv[]) {
})
.create());

// Make sure that our process symbols are visible to JIT'd code.
{
MangleAndInterner Mangle(J->getExecutionSession(), J->getDataLayout());
J->getMainJITDylib().addGenerator(
ExitOnErr(orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(
J->getDataLayout().getGlobalPrefix(),
[MainName = Mangle("main")](const orc::SymbolStringPtr &Name) {
return Name != MainName;
})));
}

// Load the input modules.
for (auto &InputFile : InputFiles) {
auto Ctx = std::make_unique<LLVMContext>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,6 @@ int main(int argc, char *argv[]) {
.create());

if (!InputObjects.empty()) {

// If we have input objects then reflect process symbols so the input
// objects can do interesting things, like call printf.
J->getMainJITDylib().addGenerator(
ExitOnErr(DynamicLibrarySearchGenerator::GetForCurrentProcess(
J->getDataLayout().getGlobalPrefix())));

// Load the input objects.
for (auto InputObject : InputObjects) {
auto ObjBuffer =
Expand Down

This file was deleted.

This file was deleted.

20 changes: 16 additions & 4 deletions llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class COFFPlatform : public Platform {

/// Try to create a COFFPlatform instance, adding the ORC runtime to the
/// given JITDylib.
static Expected<std::unique_ptr<COFFPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime = false,
const char *VCRuntimePath = nullptr,
std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);

static Expected<std::unique_ptr<COFFPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
Expand Down Expand Up @@ -136,10 +144,14 @@ class COFFPlatform : public Platform {

static bool supportedTarget(const Triple &TT);

COFFPlatform(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
LoadDynamicLibrary LoadDynamicLibrary, bool StaticVCRuntime,
const char *VCRuntimePath, Error &Err);
COFFPlatform(
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD,
std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
std::unique_ptr<object::Archive> OrcRuntimeArchive,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath, Error &Err);

// Associate COFFPlatform JIT-side runtime support functions with handlers.
Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
Expand Down

0 comments on commit 231107a

Please sign in to comment.