Attempt to fix Orc JIT test timeouts

I think there are some destruction ordering issues here. The
ShouldDelete map seems to be getting destroyed before the shared_ptr
deleter lambda accesses it. In any case, this avoids inserting elements
into the map during shutdown.

llvm-svn: 306736
This commit is contained in:
Reid Kleckner 2017-06-29 20:15:08 +00:00
parent 837c110cb1
commit f03096b3c3
1 changed files with 5 additions and 5 deletions

View File

@ -193,11 +193,11 @@ public:
} }
auto *MPtr = M.release(); auto *MPtr = M.release();
ShouldDelete[MPtr] = true; ShouldDelete[MPtr] = true;
auto Deleter = auto Deleter = [this](Module *Mod) {
[this](Module *Mod) { auto I = ShouldDelete.find(Mod);
if (ShouldDelete[Mod]) if (I != ShouldDelete.end() && I->second)
delete Mod; delete Mod;
}; };
LocalModules.push_back(std::shared_ptr<Module>(MPtr, std::move(Deleter))); LocalModules.push_back(std::shared_ptr<Module>(MPtr, std::move(Deleter)));
LazyEmitLayer.addModule(LocalModules.back(), &MemMgr, &Resolver); LazyEmitLayer.addModule(LocalModules.back(), &MemMgr, &Resolver);
} }