summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-06-14 15:32:58 +0000
committerLang Hames <lhames@gmail.com>2018-06-14 15:32:58 +0000
commit784fecfe71912a618d89cc77ea825b86df184f54 (patch)
tree96936740802956e4dbf9f01d96d7641a41d10483 /llvm/lib/ExecutionEngine
parent03395d2e58b220d455891e34c747d3c61f8d43e2 (diff)
downloadbcm5719-llvm-784fecfe71912a618d89cc77ea825b86df184f54.tar.gz
bcm5719-llvm-784fecfe71912a618d89cc77ea825b86df184f54.zip
[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. llvm-svn: 334722
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp64
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Legacy.cpp4
2 files changed, 44 insertions, 24 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index 5ae65ab2f66..74cb3834b79 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -937,7 +937,7 @@ VSO &ExecutionSession::createVSO(std::string Name) {
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(ExecutionSessionBase &ES,
}
};
- 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(ExecutionSessionBase &ES,
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(ExecutionSessionBase &ES,
}
}
- 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::VSOList &VSOs, SymbolNameSet Names) {
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.
diff --git a/llvm/lib/ExecutionEngine/Orc/Legacy.cpp b/llvm/lib/ExecutionEngine/Orc/Legacy.cpp
index 3fd53a00a79..795ddd582d8 100644
--- a/llvm/lib/ExecutionEngine/Orc/Legacy.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Legacy.cpp
@@ -27,8 +27,8 @@ JITSymbolResolverAdapter::lookup(const LookupSet &Symbols) {
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();
OpenPOWER on IntegriCloud