Skip to content

Commit 6e7a449

Browse files
authored
[MLIR] Enable dylib init/deinit in execution engine on AArch64 platform (#172833)
This PR enables JIT initialize for AArch64. Up to now it was disabled because of #71963 which was recently fixed by #71968.
1 parent 133253d commit 6e7a449

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,7 @@ ExecutionEngine::ExecutionEngine(bool enableObjectDump,
218218

219219
ExecutionEngine::~ExecutionEngine() {
220220
// Execute the global destructors from the module being processed.
221-
// TODO: Allow JIT deinitialize for AArch64. Currently there's a bug causing a
222-
// crash for AArch64 see related issue #71963.
223-
if (jit && !jit->getTargetTriple().isAArch64())
221+
if (jit)
224222
llvm::consumeError(jit->deinitialize(jit->getMainJITDylib()));
225223
// Run all dynamic library destroy callbacks to prepare for the shutdown.
226224
for (LibraryDestroyFn destroy : destroyFns)
@@ -314,10 +312,14 @@ ExecutionEngine::create(Operation *m, const ExecutionEngineOptions &options,
314312
// Callback to create the object layer with symbol resolution to current
315313
// process and dynamically linked libraries.
316314
auto objectLinkingLayerCreator = [&](ExecutionSession &session) {
315+
// Needed to respect AArch64 ABI requirements on the distance between
316+
// TEXT and GOT sections.
317+
bool reserveAlloc = llvmModule->getTargetTriple().isAArch64();
317318
auto objectLayer = std::make_unique<RTDyldObjectLinkingLayer>(
318-
session, [sectionMemoryMapper =
319-
options.sectionMemoryMapper](const MemoryBuffer &) {
320-
return std::make_unique<SectionMemoryManager>(sectionMemoryMapper);
319+
session, [sectionMemoryMapper = options.sectionMemoryMapper,
320+
reserveAlloc](const MemoryBuffer &) {
321+
return std::make_unique<SectionMemoryManager>(sectionMemoryMapper,
322+
reserveAlloc);
321323
});
322324

323325
// Register JIT event listeners if they are enabled.
@@ -449,9 +451,6 @@ Error ExecutionEngine::invokePacked(StringRef name,
449451
void ExecutionEngine::initialize() {
450452
if (isInitialized)
451453
return;
452-
// TODO: Allow JIT initialize for AArch64. Currently there's a bug causing a
453-
// crash for AArch64 see related issue #71963.
454-
if (!jit->getTargetTriple().isAArch64())
455-
cantFail(jit->initialize(jit->getMainJITDylib()));
454+
cantFail(jit->initialize(jit->getMainJITDylib()));
456455
isInitialized = true;
457456
}

0 commit comments

Comments
 (0)