diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-27 02:24:16 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-02-27 02:24:16 +0000 |
| commit | b818676f6da900d3313ddaf64a818e8ff726f1e3 (patch) | |
| tree | 30025825bdd7305667bd73216f29eba925dc3604 | |
| parent | 859e017621b396c80e3bba36340bcf4bfe5198ac (diff) | |
| download | bcm5719-llvm-b818676f6da900d3313ddaf64a818e8ff726f1e3.tar.gz bcm5719-llvm-b818676f6da900d3313ddaf64a818e8ff726f1e3.zip | |
Don't modify the DenseMap being iterated over from within the loop
that is iterating over it
Inserting elements into a `DenseMap` invalidated iterators pointing
into the `DenseMap` instance.
Differential Revision: http://reviews.llvm.org/D7924
llvm-svn: 230719
| -rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index c0d7dca2775..81a149a99e3 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -561,12 +561,15 @@ static void computeBaseDerivedRelocateMap( IntrinsicInst *I = Item.second; auto BaseKey = std::make_pair(Key.first, Key.first); - IntrinsicInst *Base = RelocateIdxMap[BaseKey]; - if (!Base) + + // We're iterating over RelocateIdxMap so we cannot modify it. + auto MaybeBase = RelocateIdxMap.find(BaseKey); + if (MaybeBase == RelocateIdxMap.end()) // TODO: We might want to insert a new base object relocate and gep off // that, if there are enough derived object relocates. continue; - RelocateInstMap[Base].push_back(I); + + RelocateInstMap[MaybeBase->second].push_back(I); } } |

