Skip to content

Commit

Permalink
[LLJIT] Allow multiple loadPlatformDynamicLibrary calls with the same…
Browse files Browse the repository at this point in the history
… path.

Where the same dylib is loaded more than once we should just return the
JITDylib created by the first call rather than error out. This matches the
behavior of dlopen / LoadLibrary.
  • Loading branch information
lhames committed Mar 27, 2023
1 parent 9a9827d commit 9cffb2f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,8 @@ Expected<JITDylib &> LLJIT::loadPlatformDynamicLibrary(const char *Path) {
if (!G)
return G.takeError();

if (ES->getJITDylibByName(Path))
return make_error<StringError>(
Twine("LLJIT ExecutionSession already contains a JITDylib named \"") +
Path + "\"",
inconvertibleErrorCode());
if (auto *ExistingJD = ES->getJITDylibByName(Path))
return *ExistingJD;

auto &JD = ES->createBareJITDylib(Path);
JD.addGenerator(std::move(*G));
Expand Down

0 comments on commit 9cffb2f

Please sign in to comment.