Fix a use-iterator-after-invalidate error

AnalysisResult::getResultImpl reuses an iterator into a DenseMap after
inserting elements into it. This change adds code to recompute the
iterator before the second use.

llvm-svn: 230718
This commit is contained in:
Sanjoy Das 2015-02-27 02:19:11 +00:00
parent 497bf5587e
commit 859e017621
1 changed files with 6 additions and 0 deletions

View File

@ -471,6 +471,12 @@ private:
dbgs() << "Running analysis: " << P.name() << "\n";
AnalysisResultListT &ResultList = AnalysisResultLists[&IR];
ResultList.emplace_back(PassID, P.run(IR, this));
// P.run may have inserted elements into AnalysisResults and invalidated
// RI.
RI = AnalysisResults.find(std::make_pair(PassID, &IR));
assert(RI != AnalysisResults.end() && "we just inserted it!");
RI->second = std::prev(ResultList.end());
}