summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-05-21 21:11:21 +0000
committerLang Hames <lhames@gmail.com>2018-05-21 21:11:21 +0000
commit0b0b41fccefbcd275dee6282b384abfb4ad03266 (patch)
tree8b44105f2f60a6cd009d3ce4ee4627e0a84c934f /llvm/lib/ExecutionEngine
parentadd9b6805c7cd593ab7290275e6d9c77fce454f4 (diff)
downloadbcm5719-llvm-0b0b41fccefbcd275dee6282b384abfb4ad03266.tar.gz
bcm5719-llvm-0b0b41fccefbcd275dee6282b384abfb4ad03266.zip
[ORC] Lookup now returns an error if any symbols are not found.
Also tightens the behavior of ExecutionSession::failQuery. Queries can usually only be failed by marking a symbol as failed-to-materialize, but ExecutionSession::failQuery provides a second route, and both routes may be executed from different threads. In the case that a query has already been failed due to a materialization error, ExecutionSession::failQuery will direct the error to ExecutionSession::reportError instead. llvm-svn: 332898
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/Core.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp
index ded8bddb468..760e2561ba6 100644
--- a/llvm/lib/ExecutionEngine/Orc/Core.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp
@@ -20,6 +20,7 @@ namespace llvm {
namespace orc {
char FailedToMaterialize::ID = 0;
+char SymbolsNotFound::ID = 0;
void MaterializationUnit::anchor() {}
void SymbolResolver::anchor() {}
@@ -110,11 +111,31 @@ void FailedToMaterialize::log(raw_ostream &OS) const {
OS << "Failed to materialize symbols: " << Symbols;
}
+SymbolsNotFound::SymbolsNotFound(SymbolNameSet Symbols)
+ : Symbols(std::move(Symbols)) {
+ assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
+}
+
+std::error_code SymbolsNotFound::convertToErrorCode() const {
+ return orcError(OrcErrorCode::UnknownORCError);
+}
+
+void SymbolsNotFound::log(raw_ostream &OS) const {
+ OS << "Symbols not found: " << Symbols;
+}
+
void ExecutionSessionBase::failQuery(AsynchronousSymbolQuery &Q, Error Err) {
+ bool DeliveredError = true;
runSessionLocked([&]() -> void {
Q.detach();
- Q.handleFailed(std::move(Err));
+ if (Q.canStillFail())
+ Q.handleFailed(std::move(Err));
+ else
+ DeliveredError = false;
});
+
+ if (!DeliveredError)
+ reportError(std::move(Err));
}
AsynchronousSymbolQuery::AsynchronousSymbolQuery(
@@ -160,6 +181,10 @@ void AsynchronousSymbolQuery::handleFullyReady() {
NotifySymbolsReady = SymbolsReadyCallback();
}
+bool AsynchronousSymbolQuery::canStillFail() {
+ return (NotifySymbolsResolved || NotifySymbolsReady);
+}
+
void AsynchronousSymbolQuery::handleFailed(Error Err) {
assert(QueryRegistrations.empty() && ResolvedSymbols.empty() &&
NotYetResolvedCount == 0 && NotYetReadyCount == 0 &&
@@ -902,7 +927,13 @@ Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names)
UnresolvedSymbols = V->lookup(Query, UnresolvedSymbols);
}
- // FIXME: Error out if there are remaining unresolved symbols.
+ if (!UnresolvedSymbols.empty()) {
+ // If there are unresolved symbols then the query will never return.
+ // Fail it with ES.failQuery.
+ auto &ES = (*VSOs.begin())->getExecutionSession();
+ ES.failQuery(*Query,
+ make_error<SymbolsNotFound>(std::move(UnresolvedSymbols)));
+ }
#if LLVM_ENABLE_THREADS
auto ResultFuture = PromisedResult.get_future();
OpenPOWER on IntegriCloud