diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-27 02:19:11 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-27 02:19:11 +0000 |
| commit | 859e017621b396c80e3bba36340bcf4bfe5198ac (patch) | |
| tree | 64dd0daca718d589926cf45922f7f5321068b94d | |
| parent | 497bf5587e11e2c271f1b4632b55e5a9258c91e9 (diff) | |
| download | bcm5719-llvm-859e017621b396c80e3bba36340bcf4bfe5198ac.tar.gz bcm5719-llvm-859e017621b396c80e3bba36340bcf4bfe5198ac.zip | |
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
| -rw-r--r-- | llvm/include/llvm/IR/PassManager.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index c92e7c91994..513bbe01da0 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -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()); } |

