From 9000ee2224708853517354818fa58dd0a9a0c0bb Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 25 Oct 2022 08:23:27 -0700 Subject: [PATCH] [ORC] Update SelfExecutorProcessControl to allow user-supplied handles. SelfExecutorProcessControl no longer requires that handles passed to lookupSymbols be ones that were previously returned from loadDylib. This brings SelfExecutorPRocessControl into alignment with SimpleRemoteEPC, which was updated in 6613f4aff85. --- .../llvm/ExecutionEngine/Orc/ExecutorProcessControl.h | 1 - .../lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp | 18 +++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h index 20f5c98..f858788 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h @@ -483,7 +483,6 @@ private: std::unique_ptr OwnedMemMgr; char GlobalManglingPrefix = 0; - std::vector> DynamicLibraries; }; } // end namespace orc diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp index b48d60b..361fcd4 100644 --- a/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp @@ -75,12 +75,10 @@ SelfExecutorProcessControl::Create( Expected SelfExecutorProcessControl::loadDylib(const char *DylibPath) { std::string ErrMsg; - auto Dylib = std::make_unique( - sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg)); - if (!Dylib->isValid()) + auto Dylib = sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg); + if (!Dylib.isValid()) return make_error(std::move(ErrMsg), inconvertibleErrorCode()); - DynamicLibraries.push_back(std::move(Dylib)); - return ExecutorAddr::fromPtr(DynamicLibraries.back().get()); + return ExecutorAddr::fromPtr(Dylib.getOSSpecificHandle()); } Expected> @@ -88,19 +86,13 @@ SelfExecutorProcessControl::lookupSymbols(ArrayRef Request) { std::vector R; for (auto &Elem : Request) { - auto *Dylib = Elem.Handle.toPtr(); - assert(llvm::any_of(DynamicLibraries, - [=](const std::unique_ptr &DL) { - return DL.get() == Dylib; - }) && - "Invalid handle"); - + sys::DynamicLibrary Dylib(Elem.Handle.toPtr()); R.push_back(std::vector()); for (auto &KV : Elem.Symbols) { auto &Sym = KV.first; std::string Tmp((*Sym).data() + !!GlobalManglingPrefix, (*Sym).size() - !!GlobalManglingPrefix); - void *Addr = Dylib->getAddressOfSymbol(Tmp.c_str()); + void *Addr = Dylib.getAddressOfSymbol(Tmp.c_str()); if (!Addr && KV.second == SymbolLookupFlags::RequiredSymbol) { // FIXME: Collect all failing symbols before erroring out. SymbolNameVector MissingSymbols; -- 2.7.4