forked from OSchip/llvm-project
[ORC] Hold shared_ptr<SymbolStringPool> in errors containing SymbolStringPtrs.
This allows these error values to remain valid, even if they tear down the JIT itself.
This commit is contained in:
parent
c42772752a
commit
6fe2e9a9cc
|
@ -433,13 +433,16 @@ class SymbolsNotFound : public ErrorInfo<SymbolsNotFound> {
|
|||
public:
|
||||
static char ID;
|
||||
|
||||
SymbolsNotFound(SymbolNameSet Symbols);
|
||||
SymbolsNotFound(SymbolNameVector Symbols);
|
||||
SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP, SymbolNameSet Symbols);
|
||||
SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
|
||||
SymbolNameVector Symbols);
|
||||
std::error_code convertToErrorCode() const override;
|
||||
void log(raw_ostream &OS) const override;
|
||||
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
|
||||
const SymbolNameVector &getSymbols() const { return Symbols; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<SymbolStringPool> SSP;
|
||||
SymbolNameVector Symbols;
|
||||
};
|
||||
|
||||
|
@ -448,12 +451,15 @@ class SymbolsCouldNotBeRemoved : public ErrorInfo<SymbolsCouldNotBeRemoved> {
|
|||
public:
|
||||
static char ID;
|
||||
|
||||
SymbolsCouldNotBeRemoved(SymbolNameSet Symbols);
|
||||
SymbolsCouldNotBeRemoved(std::shared_ptr<SymbolStringPool> SSP,
|
||||
SymbolNameSet Symbols);
|
||||
std::error_code convertToErrorCode() const override;
|
||||
void log(raw_ostream &OS) const override;
|
||||
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
|
||||
const SymbolNameSet &getSymbols() const { return Symbols; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<SymbolStringPool> SSP;
|
||||
SymbolNameSet Symbols;
|
||||
};
|
||||
|
||||
|
@ -465,13 +471,17 @@ class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
|
|||
public:
|
||||
static char ID;
|
||||
|
||||
MissingSymbolDefinitions(std::string ModuleName, SymbolNameVector Symbols)
|
||||
: ModuleName(std::move(ModuleName)), Symbols(std::move(Symbols)) {}
|
||||
MissingSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
|
||||
std::string ModuleName, SymbolNameVector Symbols)
|
||||
: SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
|
||||
Symbols(std::move(Symbols)) {}
|
||||
std::error_code convertToErrorCode() const override;
|
||||
void log(raw_ostream &OS) const override;
|
||||
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
|
||||
const std::string &getModuleName() const { return ModuleName; }
|
||||
const SymbolNameVector &getSymbols() const { return Symbols; }
|
||||
private:
|
||||
std::shared_ptr<SymbolStringPool> SSP;
|
||||
std::string ModuleName;
|
||||
SymbolNameVector Symbols;
|
||||
};
|
||||
|
@ -484,13 +494,17 @@ class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions
|
|||
public:
|
||||
static char ID;
|
||||
|
||||
UnexpectedSymbolDefinitions(std::string ModuleName, SymbolNameVector Symbols)
|
||||
: ModuleName(std::move(ModuleName)), Symbols(std::move(Symbols)) {}
|
||||
UnexpectedSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
|
||||
std::string ModuleName, SymbolNameVector Symbols)
|
||||
: SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
|
||||
Symbols(std::move(Symbols)) {}
|
||||
std::error_code convertToErrorCode() const override;
|
||||
void log(raw_ostream &OS) const override;
|
||||
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
|
||||
const std::string &getModuleName() const { return ModuleName; }
|
||||
const SymbolNameVector &getSymbols() const { return Symbols; }
|
||||
private:
|
||||
std::shared_ptr<SymbolStringPool> SSP;
|
||||
std::string ModuleName;
|
||||
SymbolNameVector Symbols;
|
||||
};
|
||||
|
@ -1310,6 +1324,11 @@ public:
|
|||
/// ExecutionSession.
|
||||
ExecutorProcessControl &getExecutorProcessControl() { return *EPC; }
|
||||
|
||||
/// Get the SymbolStringPool for this instance.
|
||||
std::shared_ptr<SymbolStringPool> getSymbolStringPool() {
|
||||
return EPC->getSymbolStringPool();
|
||||
}
|
||||
|
||||
/// Add a symbol name to the SymbolStringPool and return a pointer to it.
|
||||
SymbolStringPtr intern(StringRef SymName) { return EPC->intern(SymName); }
|
||||
|
||||
|
|
|
@ -90,14 +90,17 @@ void FailedToMaterialize::log(raw_ostream &OS) const {
|
|||
OS << "Failed to materialize symbols: " << *Symbols;
|
||||
}
|
||||
|
||||
SymbolsNotFound::SymbolsNotFound(SymbolNameSet Symbols) {
|
||||
SymbolsNotFound::SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
|
||||
SymbolNameSet Symbols)
|
||||
: SSP(std::move(SSP)) {
|
||||
for (auto &Sym : Symbols)
|
||||
this->Symbols.push_back(Sym);
|
||||
assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
|
||||
}
|
||||
|
||||
SymbolsNotFound::SymbolsNotFound(SymbolNameVector Symbols)
|
||||
: Symbols(std::move(Symbols)) {
|
||||
SymbolsNotFound::SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
|
||||
SymbolNameVector Symbols)
|
||||
: SSP(std::move(SSP)), Symbols(std::move(Symbols)) {
|
||||
assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
|
||||
}
|
||||
|
||||
|
@ -109,8 +112,9 @@ void SymbolsNotFound::log(raw_ostream &OS) const {
|
|||
OS << "Symbols not found: " << Symbols;
|
||||
}
|
||||
|
||||
SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved(SymbolNameSet Symbols)
|
||||
: Symbols(std::move(Symbols)) {
|
||||
SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved(
|
||||
std::shared_ptr<SymbolStringPool> SSP, SymbolNameSet Symbols)
|
||||
: SSP(std::move(SSP)), Symbols(std::move(Symbols)) {
|
||||
assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
|
||||
}
|
||||
|
||||
|
@ -1333,11 +1337,13 @@ Error JITDylib::remove(const SymbolNameSet &Names) {
|
|||
|
||||
// If any of the symbols are not defined, return an error.
|
||||
if (!Missing.empty())
|
||||
return make_error<SymbolsNotFound>(std::move(Missing));
|
||||
return make_error<SymbolsNotFound>(ES.getSymbolStringPool(),
|
||||
std::move(Missing));
|
||||
|
||||
// If any of the symbols are currently materializing, return an error.
|
||||
if (!Materializing.empty())
|
||||
return make_error<SymbolsCouldNotBeRemoved>(std::move(Materializing));
|
||||
return make_error<SymbolsCouldNotBeRemoved>(ES.getSymbolStringPool(),
|
||||
std::move(Materializing));
|
||||
|
||||
// Remove the symbols.
|
||||
for (auto &SymbolMaterializerItrPair : SymbolsToRemove) {
|
||||
|
@ -2234,7 +2240,8 @@ Error ExecutionSession::IL_updateCandidatesFor(
|
|||
// weakly referenced" specific error here to reduce confusion.
|
||||
if (SymI->second.getFlags().hasMaterializationSideEffectsOnly() &&
|
||||
SymLookupFlags != SymbolLookupFlags::WeaklyReferencedSymbol)
|
||||
return make_error<SymbolsNotFound>(SymbolNameVector({Name}));
|
||||
return make_error<SymbolsNotFound>(getSymbolStringPool(),
|
||||
SymbolNameVector({Name}));
|
||||
|
||||
// If we matched against this symbol but it is in the error state
|
||||
// then bail out and treat it as a failure to materialize.
|
||||
|
@ -2422,7 +2429,7 @@ void ExecutionSession::OL_applyQueryPhase1(
|
|||
} else {
|
||||
LLVM_DEBUG(dbgs() << "Phase 1 failed with unresolved symbols.\n");
|
||||
IPLS->fail(make_error<SymbolsNotFound>(
|
||||
IPLS->DefGeneratorCandidates.getSymbolNames()));
|
||||
getSymbolStringPool(), IPLS->DefGeneratorCandidates.getSymbolNames()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2492,7 +2499,8 @@ void ExecutionSession::OL_completeLookup(
|
|||
dbgs() << "error: "
|
||||
"required, but symbol is has-side-effects-only\n";
|
||||
});
|
||||
return make_error<SymbolsNotFound>(SymbolNameVector({Name}));
|
||||
return make_error<SymbolsNotFound>(getSymbolStringPool(),
|
||||
SymbolNameVector({Name}));
|
||||
}
|
||||
|
||||
// If we matched against this symbol but it is in the error state
|
||||
|
@ -2606,7 +2614,8 @@ void ExecutionSession::OL_completeLookup(
|
|||
|
||||
if (!IPLS->LookupSet.empty()) {
|
||||
LLVM_DEBUG(dbgs() << "Failing due to unresolved symbols\n");
|
||||
return make_error<SymbolsNotFound>(IPLS->LookupSet.getSymbolNames());
|
||||
return make_error<SymbolsNotFound>(getSymbolStringPool(),
|
||||
IPLS->LookupSet.getSymbolNames());
|
||||
}
|
||||
|
||||
// Record whether the query completed.
|
||||
|
@ -2733,7 +2742,8 @@ void ExecutionSession::OL_completeLookupFlags(
|
|||
|
||||
if (!IPLS->LookupSet.empty()) {
|
||||
LLVM_DEBUG(dbgs() << "Failing due to unresolved symbols\n");
|
||||
return make_error<SymbolsNotFound>(IPLS->LookupSet.getSymbolNames());
|
||||
return make_error<SymbolsNotFound>(getSymbolStringPool(),
|
||||
IPLS->LookupSet.getSymbolNames());
|
||||
}
|
||||
|
||||
LLVM_DEBUG(dbgs() << "Succeded, result = " << Result << "\n");
|
||||
|
|
|
@ -93,7 +93,7 @@ SelfExecutorProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
|
|||
// FIXME: Collect all failing symbols before erroring out.
|
||||
SymbolNameVector MissingSymbols;
|
||||
MissingSymbols.push_back(Sym);
|
||||
return make_error<SymbolsNotFound>(std::move(MissingSymbols));
|
||||
return make_error<SymbolsNotFound>(SSP, std::move(MissingSymbols));
|
||||
}
|
||||
R.back().push_back(pointerToJITTargetAddress(Addr));
|
||||
}
|
||||
|
|
|
@ -279,8 +279,9 @@ public:
|
|||
|
||||
// If there were missing symbols then report the error.
|
||||
if (!MissingSymbols.empty())
|
||||
return make_error<MissingSymbolDefinitions>(G.getName(),
|
||||
std::move(MissingSymbols));
|
||||
return make_error<MissingSymbolDefinitions>(
|
||||
Layer.getExecutionSession().getSymbolStringPool(), G.getName(),
|
||||
std::move(MissingSymbols));
|
||||
|
||||
// If there are more definitions than expected, add them to the
|
||||
// ExtraSymbols vector.
|
||||
|
@ -293,8 +294,9 @@ public:
|
|||
|
||||
// If there were extra definitions then report the error.
|
||||
if (!ExtraSymbols.empty())
|
||||
return make_error<UnexpectedSymbolDefinitions>(G.getName(),
|
||||
std::move(ExtraSymbols));
|
||||
return make_error<UnexpectedSymbolDefinitions>(
|
||||
Layer.getExecutionSession().getSymbolStringPool(), G.getName(),
|
||||
std::move(ExtraSymbols));
|
||||
}
|
||||
|
||||
if (auto Err = MR->notifyResolved(InternedResult))
|
||||
|
|
Loading…
Reference in New Issue