that is iterating over it
Inserting elements into a `DenseMap` invalidated iterators pointing
into the `DenseMap` instance.
Differential Revision: http://reviews.llvm.org/D7924
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230719
91177308-0d34-0410-b5e6-
96231b3b80d8
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);
}
}