<div dir="ltr">Recently I added a level to clang's debug info (-debug-info-kind=constructor) based on Reid's constructor type homing idea. Since classes typically live in header files and have no natural "home", class type information is emitted in every translation unit where it is required to be complete, which results in a lot of duplicate debug info. Constructor type homing attempts to reduce the amount of duplicate debug info by emitting debug info for classes only where the constructor is emitted. It's based on the assumption that if complete debug info for a class is needed, then it should be constructed somewhere in the program. Currently this applies to classes with nontrivial, user-defined constructors. For classes with no constructors or no nontrivial constructors, there is no change, so debug info is still emitted everywhere. This RFC proposes using constructor homing as part of clang's limited debug info level. <br><br>Currently clang's limited debug info mode already has some optimizations for limiting the amount of class debug info; for example, we emit debug info for dynamic classes only when the vtable is emitted, since the program will fail to link if the vtable is not provided. <br><br>Link to the original patch adding `-debug-info-kind=constructor`: <a href="https://reviews.llvm.org/D72427">https://reviews.llvm.org/D72427</a> <br>Patch for the proposed change: <a href="https://reviews.llvm.org/D79147">https://reviews.llvm.org/D79147</a> <br><br><b>Some numbers from the LLVM build</b><br>This is a comparison I did on my machine of total object file size in Clang debug builds, with and without constructor homing (-debug-info-kind=limited vs. constructor). In general it seems to reduce the total object file size by 30-50%.<br>on Linux<br>before: 9345 MB<br>after: 4553 MB<br><br>on Windows<br>before: 6096 MB<br>after: 3979 MB<br><br>We also enabled this in Chromium a few months ago, and saw a similar change in object / split dwarf file size.<br><br><b>Testing</b><br>There isn't a very comprehensive way that I know of to test debug info. I tested a few things:<br>- Ran the LLDB test suite with this change as part of -debug-info-kind=limited. This caught an edge case with constexpr constructors. After fixing this, the LLDB test suite now passes with this mode (minus one test case that happens to fail, and is updated in the proposed patch)<br>-Compared clang.pdb files in a Windows LLVM debug build, and looked at the list of types that are no longer complete with the constructor homing change. We looked into some of these types, and they are constructed in functions that aren't used in clang.exe. In this case, it makes sense to not emit complete debug information. <br>-Enabled this in Chromium and we haven't yet received any bug reports about debug info. <br><br>We talked about running the GDB test suite with Clang in this mode, but the GDB test suite doesn't currently pass with Clang. Triaging GDB test suite failures is probably more than a month of work, so we don't plan to pursue it.<br><br>Any feedback is welcome! Especially looking for opinions on whether this should be the default for limited debug info, or if more testing is preferred, what that might look like. <br><br>-Amy<br></div>