Skip to content

Commit b818676

Browse files
committedFeb 27, 2015
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
1 parent 859e017 commit b818676

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎llvm/lib/CodeGen/CodeGenPrepare.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -561,12 +561,15 @@ static void computeBaseDerivedRelocateMap(
561561

562562
IntrinsicInst *I = Item.second;
563563
auto BaseKey = std::make_pair(Key.first, Key.first);
564-
IntrinsicInst *Base = RelocateIdxMap[BaseKey];
565-
if (!Base)
564+
565+
// We're iterating over RelocateIdxMap so we cannot modify it.
566+
auto MaybeBase = RelocateIdxMap.find(BaseKey);
567+
if (MaybeBase == RelocateIdxMap.end())
566568
// TODO: We might want to insert a new base object relocate and gep off
567569
// that, if there are enough derived object relocates.
568570
continue;
569-
RelocateInstMap[Base].push_back(I);
571+
572+
RelocateInstMap[MaybeBase->second].push_back(I);
570573
}
571574
}
572575

0 commit comments

Comments
 (0)
Please sign in to comment.