[llvm] r332898 - [ORC] Lookup now returns an error if any symbols are not found.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 14:11:22 PDT 2018
Author: lhames
Date: Mon May 21 14:11:21 2018
New Revision: 332898
URL: http://llvm.org/viewvc/llvm-project?rev=332898&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h
llvm/trunk/lib/ExecutionEngine/Orc/Core.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=332898&r1=332897&r2=332898&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Core.h Mon May 21 14:11:21 2018
@@ -79,6 +79,20 @@ private:
SymbolNameSet Symbols;
};
+/// Used to notify clients when symbols can not be found during a lookup.
+class SymbolsNotFound : public ErrorInfo<SymbolsNotFound> {
+public:
+ static char ID;
+
+ SymbolsNotFound(SymbolNameSet Symbols);
+ std::error_code convertToErrorCode() const override;
+ void log(raw_ostream &OS) const override;
+ const SymbolNameSet &getSymbols() const { return Symbols; }
+
+private:
+ SymbolNameSet Symbols;
+};
+
/// Tracks responsibility for materialization, and mediates interactions between
/// MaterializationUnits and VSOs.
///
@@ -366,6 +380,8 @@ private:
void removeQueryDependence(VSO &V, const SymbolStringPtr &Name);
+ bool canStillFail();
+
void handleFailed(Error Err);
void detach();
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp?rev=332898&r1=332897&r2=332898&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp Mon May 21 14:11:21 2018
@@ -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_ostrea
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::handleFull
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::ve
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();
More information about the llvm-commits
mailing list