As noted in the review thread for http://reviews.llvm.org/D18477 on llvm-commits, DWARF consumers such as dtrace's ctfconvert expect debug info for types to survive even if the underlying code that references those types has been optimized away.
This patch moves this logic from the backend, where it used to be unconditionally executed, into clang. For more info on this functionality check out DwarfDebug::collectDeadVariables(), added in r107027.
This code in this patch listens to the driver option -gfull, and lowers it to the new cc1 option -debug-retain-types (1).
When -debug-retain-types is present, CGDebugInfo will retain every(2) type it creates.
Implementation notes:
- I decided not use -fno-eliminate-unused-debug-symbols for consistency with our other cc1 debug options.
- I’m minimizing the set of retained types by only retaining top-level types.