This is an archive of the discontinued LLVM Phabricator instance.

[WinEH] Avoid holding references to BlockColor (DenseMap) entries while inserting new elements
ClosedPublic

Authored by andrew.w.kaylor on Dec 12 2016, 5:50 PM.

Details

Summary

I ran into a case where the spec2006/483 test was crashing during compilation because the WinEHPrepare pass was inserting a new element into a DenseMap while holding a reference to an existing element and the insertion caused the map to be reallocated. Near as I can tell, what WinEHPrepare was doing would have been legal with an std::map but isn't guaranteed to work with DenseMap.

Diff Detail

Repository
rL LLVM

Event Timeline

andrew.w.kaylor retitled this revision from to [WinEH] Avoid holding references to BlockColor (DenseMap) entries while inserting new elements.
andrew.w.kaylor updated this object.
andrew.w.kaylor added a reviewer: rnk.
andrew.w.kaylor set the repository for this revision to rL LLVM.
andrew.w.kaylor added a subscriber: llvm-commits.
rnk accepted this revision.Dec 13 2016, 10:14 AM
rnk edited edge metadata.

lgtm

lib/CodeGen/WinEHPrepare.cpp
1205–1207 ↗(On Diff #81167)

This can be shortened to something like "Insert NewBlock before looking up PHIBlock to avoid dangling references.". Anyone familiar with DenseMap should know how the iterator invalidation guarantees differ from std::map.

This revision is now accepted and ready to land.Dec 13 2016, 10:14 AM
This revision was automatically updated to reflect the committed changes.