Fix a DenseMap iterator invalidation bug causing lots of crashes when
authorChandler Carruth <chandlerc@gmail.com>
Mon, 20 Jan 2014 08:07:07 +0000 (08:07 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 20 Jan 2014 08:07:07 +0000 (08:07 +0000)
commitd15717170fbaaa24dacf2afbd8c6e9d8da4e8fa3
tree293d9bdf885519c79b6fdbe2229ad7dc3390bf5e
parent1e1446bf84a6a36366c40f995e68ca6a460c9839
Fix a DenseMap iterator invalidation bug causing lots of crashes when
type units were enabled. The crux of the issue is that the
addDwarfTypeUnitType routine can end up being indirectly recursive. In
this case, the reference into the dense map (TU) became invalid by the
time we popped all the way back and used it to add the DIE type
signature.

Instead, use early return in the case where we can bypass the recursive
step and creating a type unit. Then use the pointer to the new type unit
to set up the DIE type signature in the case where we have to.

I tried really hard to reduce a testcase for this, but it's really
annoying. You have to get this to be mid-recursion when the densemap
grows. Even if we got a test case for this today, it'd be very unlikely
to continue exercising this pattern.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199630 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/AsmPrinter/DwarfDebug.cpp