[ORC] Fix an overly aggressive assert.

Symbols that have not been queried will not have MaterializingInfo entries,
so remove the assert that all failed symbols should have these entries.
Also updates the loop to only remove entries that were found earlier.

llvm-svn: 369975
This commit is contained in:
Lang Hames 2019-08-26 21:42:47 +00:00
parent 1266191d6f
commit 8ec9661870
2 changed files with 35 additions and 3 deletions

View File

@ -1187,6 +1187,8 @@ void JITDylib::notifyFailed(const SymbolFlagsMap &FailedSymbols) {
AsynchronousSymbolQuerySet FailedQueries;
ES.runSessionLocked([&]() {
std::vector<const SymbolStringPtr *> MaterializerNamesToFail;
for (auto &KV : FailedSymbols) {
auto &Name = KV.first;
@ -1207,6 +1209,7 @@ void JITDylib::notifyFailed(const SymbolFlagsMap &FailedSymbols) {
continue;
auto &MI = MII->second;
MaterializerNamesToFail.push_back(&KV.first);
// Move all dependants to the error state and disconnect from them.
for (auto &KV : MI.Dependants) {
@ -1261,9 +1264,9 @@ void JITDylib::notifyFailed(const SymbolFlagsMap &FailedSymbols) {
Q->detach();
// Remove the MaterializingInfos.
for (auto &KV : FailedSymbols) {
assert(MaterializingInfos.count(KV.first) && "Expected MI for Name");
MaterializingInfos.erase(KV.first);
while (!MaterializerNamesToFail.empty()) {
MaterializingInfos.erase(*MaterializerNamesToFail.back());
MaterializerNamesToFail.pop_back();
}
});

View File

@ -718,6 +718,35 @@ TEST_F(CoreAPIsStandardTest, AddDependencyOnFailedSymbol) {
<< "Lookup on failed symbol should fail";
}
TEST_F(CoreAPIsStandardTest, FailMaterializerWithUnqueriedSymbols) {
// Make sure that symbols with no queries aganist them still
// fail correctly.
bool MaterializerRun = false;
auto MU = std::make_unique<SimpleMaterializationUnit>(
SymbolFlagsMap(
{{Foo, JITSymbolFlags::Exported}, {Bar, JITSymbolFlags::Exported}}),
[&](MaterializationResponsibility R) {
MaterializerRun = true;
R.failMaterialization();
});
cantFail(JD.define(std::move(MU)));
// Issue a query for Foo, but not bar.
EXPECT_THAT_EXPECTED(ES.lookup({&JD}, {Foo}), Failed())
<< "Expected lookup to fail.";
// Check that the materializer (and therefore failMaterialization) ran.
EXPECT_TRUE(MaterializerRun) << "Expected materializer to have run by now";
// Check that subsequent queries against both symbols fail.
EXPECT_THAT_EXPECTED(ES.lookup({&JD}, {Foo}), Failed())
<< "Expected lookup for Foo to fail.";
EXPECT_THAT_EXPECTED(ES.lookup({&JD}, {Bar}), Failed())
<< "Expected lookup for Bar to fail.";
}
TEST_F(CoreAPIsStandardTest, DropMaterializerWhenEmpty) {
bool DestructorRun = false;