[llvm] r334722 - [ORC] Add a WaitUntilReady argument to blockingLookup.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 14 08:32:58 PDT 2018
Author: lhames
Date: Thu Jun 14 08:32:58 2018
New Revision: 334722
URL: http://llvm.org/viewvc/llvm-project?rev=334722&view=rev
Log:
[ORC] Add a WaitUntilReady argument to blockingLookup.
If WaitUntilReady is set to true then blockingLookup will return once all
requested symbols are ready. If WaitUntilReady is set to false then
blockingLookup will return as soon as all requested symbols have been
resolved. In the latter case, if any error occurs in finalizing the symbols it
will be reported to the ExecutionSession, rather than returned by
blockingLookup.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h
llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
llvm/trunk/lib/ExecutionEngine/Orc/Legacy.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h?rev=334722&r1=334721&r2=334722&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h Thu Jun 14 08:32:58 2018
@@ -639,7 +639,7 @@ using AsynchronousLookupFunction = std::
/// Perform a blocking lookup on the given symbols.
Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES,
AsynchronousLookupFunction AsyncLookup,
- SymbolNameSet Names,
+ SymbolNameSet Names, bool WaiUntilReady,
MaterializationResponsibility *MR = nullptr);
/// Look up the given names in the given VSOs.
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp?rev=334722&r1=334721&r2=334722&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp Thu Jun 14 08:32:58 2018
@@ -937,7 +937,7 @@ VSO &ExecutionSession::createVSO(std::st
Expected<SymbolMap> blockingLookup(ExecutionSessionBase &ES,
AsynchronousLookupFunction AsyncLookup,
- SymbolNameSet Names,
+ SymbolNameSet Names, bool WaitUntilReady,
MaterializationResponsibility *MR) {
#if LLVM_ENABLE_THREADS
@@ -963,14 +963,23 @@ Expected<SymbolMap> blockingLookup(Execu
}
};
- auto OnReady = [&](Error Err) {
- if (Err) {
- ErrorAsOutParameter _(&ReadyError);
- std::lock_guard<std::mutex> Lock(ErrMutex);
- ReadyError = std::move(Err);
- }
- PromisedReady.set_value();
- };
+ std::function<void(Error)> OnReady;
+ if (WaitUntilReady) {
+ OnReady = [&](Error Err) {
+ if (Err) {
+ ErrorAsOutParameter _(&ReadyError);
+ std::lock_guard<std::mutex> Lock(ErrMutex);
+ ReadyError = std::move(Err);
+ }
+ PromisedReady.set_value();
+ };
+ } else {
+ OnReady = [&](Error Err) {
+ if (Err)
+ ES.reportError(std::move(Err));
+ };
+ }
+
#else
SymbolMap Result;
Error ResolutionError = Error::success();
@@ -986,11 +995,19 @@ Expected<SymbolMap> blockingLookup(Execu
ResolutionError = R.takeError();
};
- auto OnReady = [&](Error Err) {
- ErrorAsOutParameter _(&ReadyError);
- if (Err)
- ReadyError = std::move(Err);
- };
+ std::function<void(Error)> OnReady;
+ if (WaitUntilReady) {
+ OnReady = [&](Error Err) {
+ ErrorAsOutParameter _(&ReadyError);
+ if (Err)
+ ReadyError = std::move(Err);
+ };
+ } else {
+ OnReady = [&](Error Err) {
+ if (Err)
+ ES.reportError(std::move(Err));
+ };
+ }
#endif
auto Query = std::make_shared<AsynchronousSymbolQuery>(
@@ -1017,14 +1034,17 @@ Expected<SymbolMap> blockingLookup(Execu
}
}
- auto ReadyFuture = PromisedReady.get_future();
- ReadyFuture.get();
+ if (WaitUntilReady) {
+ auto ReadyFuture = PromisedReady.get_future();
+ ReadyFuture.get();
- {
- std::lock_guard<std::mutex> Lock(ErrMutex);
- if (ReadyError)
- return std::move(ReadyError);
- }
+ {
+ std::lock_guard<std::mutex> Lock(ErrMutex);
+ if (ReadyError)
+ return std::move(ReadyError);
+ }
+ } else
+ cantFail(std::move(ReadyError));
return std::move(Result);
@@ -1060,7 +1080,7 @@ Expected<SymbolMap> lookup(const VSO::VS
return Unresolved;
};
- return blockingLookup(ES, std::move(LookupFn), Names);
+ return blockingLookup(ES, std::move(LookupFn), Names, true);
}
/// Look up a symbol by searching a list of VSOs.
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Legacy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Legacy.cpp?rev=334722&r1=334721&r2=334722&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Legacy.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Legacy.cpp Thu Jun 14 08:32:58 2018
@@ -27,8 +27,8 @@ JITSymbolResolverAdapter::lookup(const L
return R.lookup(std::move(Q), std::move(Unresolved));
};
- auto InternedResult =
- blockingLookup(ES, std::move(LookupFn), std::move(InternedSymbols), MR);
+ auto InternedResult = blockingLookup(ES, std::move(LookupFn),
+ std::move(InternedSymbols), false, MR);
if (!InternedResult)
return InternedResult.takeError();
More information about the llvm-commits
mailing list