Skip to content

Commit 9000ee2

Browse files
committed
[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 6613f4a.
1 parent 5be51ac commit 9000ee2

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

llvm/include/llvm/ExecutionEngine/Orc/ExecutorProcessControl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ class SelfExecutorProcessControl
483483

484484
std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
485485
char GlobalManglingPrefix = 0;
486-
std::vector<std::unique_ptr<sys::DynamicLibrary>> DynamicLibraries;
487486
};
488487

489488
} // end namespace orc

llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,24 @@ SelfExecutorProcessControl::Create(
7575
Expected<tpctypes::DylibHandle>
7676
SelfExecutorProcessControl::loadDylib(const char *DylibPath) {
7777
std::string ErrMsg;
78-
auto Dylib = std::make_unique<sys::DynamicLibrary>(
79-
sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg));
80-
if (!Dylib->isValid())
78+
auto Dylib = sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg);
79+
if (!Dylib.isValid())
8180
return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
82-
DynamicLibraries.push_back(std::move(Dylib));
83-
return ExecutorAddr::fromPtr(DynamicLibraries.back().get());
81+
return ExecutorAddr::fromPtr(Dylib.getOSSpecificHandle());
8482
}
8583

8684
Expected<std::vector<tpctypes::LookupResult>>
8785
SelfExecutorProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
8886
std::vector<tpctypes::LookupResult> R;
8987

9088
for (auto &Elem : Request) {
91-
auto *Dylib = Elem.Handle.toPtr<sys::DynamicLibrary *>();
92-
assert(llvm::any_of(DynamicLibraries,
93-
[=](const std::unique_ptr<sys::DynamicLibrary> &DL) {
94-
return DL.get() == Dylib;
95-
}) &&
96-
"Invalid handle");
97-
89+
sys::DynamicLibrary Dylib(Elem.Handle.toPtr<void *>());
9890
R.push_back(std::vector<ExecutorAddr>());
9991
for (auto &KV : Elem.Symbols) {
10092
auto &Sym = KV.first;
10193
std::string Tmp((*Sym).data() + !!GlobalManglingPrefix,
10294
(*Sym).size() - !!GlobalManglingPrefix);
103-
void *Addr = Dylib->getAddressOfSymbol(Tmp.c_str());
95+
void *Addr = Dylib.getAddressOfSymbol(Tmp.c_str());
10496
if (!Addr && KV.second == SymbolLookupFlags::RequiredSymbol) {
10597
// FIXME: Collect all failing symbols before erroring out.
10698
SymbolNameVector MissingSymbols;

0 commit comments

Comments
 (0)