mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[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
This commit is contained in:
parent
2df7bb6df6
commit
a779e0266f
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user