Page MenuHomePhabricator

Drop debug info for DISubprograms that are not referenced by anything
ClosedPublic

Authored by aprantl on Mar 25 2016, 10:22 AM.

Details

Summary

This patch drops the debug info for all DISubprograms that are
(a) not attached to an llvm::Function and
(b) not indirectly reachable via inline scopes from any surviving Function and
(c) not reachable from a type (i.e.: member functions).

Background: I'm currently working on a patch to reverse the pointers between DICompileUnit and DISubprogram (for more info check Duncan's RFC on lazy-loading of debug info metadata http://lists.llvm.org/pipermail/llvm-dev/2016-March/097419.html). The idea is to remove the list of subprograms from DICompileUnit and instead point to the owning compile unit from each DISubprogram. After doing this all DISubprograms fulfilling the above criteria will be implicitly dropped unless we go through an extra effort to preserve them. Since there is not much value in preserving DISubprograms that have been optimized away entirely (as in: not even inlined) I'm proposing to just drop them entirely and save some space.

Diff Detail

Event Timeline

aprantl updated this revision to Diff 51650.Mar 25 2016, 10:22 AM
aprantl retitled this revision from to Drop debug info for DISubprograms that are not referenced by anything.
aprantl updated this object.
aprantl set the repository for this revision to rL LLVM.
aprantl added a subscriber: llvm-commits.
aprantl updated this revision to Diff 51654.Mar 25 2016, 10:24 AM

rebased patch on ToT.

dblaikie edited edge metadata.Mar 25 2016, 10:32 AM

Any particular benefit of doing this before doing the remapping from subprogram->cu? (I guess it means doing some of the test case cleanup first, and the change is pretty small - but we'll want to remove those code changes once the remapping is done, right?)

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
529–530

This is usually just written without the != 0

test/DebugInfo/X86/debug-dead-local-var.ll
14–16

Have you checked the commit history for this? It looks pretty deliberate, and while I suspect even if it was we probably still want to make the change you're making - but it'd be good to check the historic reasoning, etc.

Any particular benefit of doing this before doing the remapping from subprogram->cu? (I guess it means doing some of the test case cleanup first, and the change is pretty small - but we'll want to remove those code changes once the remapping is done, right?)

Yes. Doing this first means that the remapping becomes an "NFC" commit (if we disregard the bitcode format).

aprantl updated this revision to Diff 51671.Mar 25 2016, 12:21 PM
aprantl edited edge metadata.
aprantl removed rL LLVM as the repository for this revision.
  • delete the now dead collectDeadVariables().
  • drop a redundant != 0.

Digging further through the commit (and radar) history this feature has been added to support dtrace.
Instead of having everyone pay for this, I think it would be a more appropriate resolution for this to add something like a -gfull option to clang that retains every type in the compile unit.

Ok, given that the potential issue with dtrace is handled in D18565, are there any other comments on this patch?

aprantl updated this revision to Diff 52621.Apr 4 2016, 1:37 PM

Forgot to remove the collectDeadVariables function declaration.

aprantl marked 2 inline comments as done.Apr 7 2016, 8:56 AM
dblaikie accepted this revision.Apr 8 2016, 2:02 PM
dblaikie edited edge metadata.

Looks good, thanks - I assume a bunch of this will get simpler once you actually reverse the subprogram<>compile unit mapping? (like the extra check added at DwarfDebug.cpp:530)

Also, do you have any numbers of debug info size changes? I imagine this reduces DWARF size perhaps noticeably for linkonce functions?

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
531–533

Did some formatting get changed here? ^ (Phab shows no diff highlight, but that the forBothCUs doesn't line up with the closing '});'

This revision is now accepted and ready to land.Apr 8 2016, 2:02 PM

Here's some data:

Baseline (compiling llc RelWithDebugAsserts)

find lib-OLD -name '*.o' | xargs dwarfdump --file-stats

  File       symtab            strtab            code data         DWARF debug       STABS debug       other             file
 =========  ================= ================= ================= ================= ================= ================= =======================================
1449525800    1417344   0.10%   5616761   0.39%  26037272   1.80%1349841343  93.12%         0   0.00%  66613080   4.60%
Average sizes:
   1884949       1843   0.10%      7303   0.39%     33858   1.80%   1755320  93.12%         0   0.00%     86622   4.60%

with this patch:

find lib -name '*.o' | xargs dwarfdump --file-stats

 File       symtab            strtab            code data         DWARF debug       STABS debug       other             file
 =========  ================= ================= ================= ================= ================= ================= =======================================
1449515428    1417280   0.10%   5616555   0.39%  26036518   1.80%1349833958  93.12%         0   0.00%  66611117   4.60%
Average sizes:
   1884935       1843   0.10%      7303   0.39%     33857   1.80%   1755310  93.12%         0   0.00%     86620   4.60%

We're saving a hot 7kb of DWARF on llc.

It turns out that I messed up while rebasing the patch. We save 20kb on llc.

Baseline:

 File       symtab            strtab            code data         DWARF debug       STABS debug       other             file
 =========  ================= ================= ================= ================= ================= ================= =======================================

1449525800    1417344   0.10%   5616761   0.39%  26037272   1.80%1349841343  93.12%         0   0.00%  66613080   4.60%
Average sizes:
   1884949       1843   0.10%      7303   0.39%     33858   1.80%   1755320  93.12%         0   0.00%     86622   4.60%

New:

 File       symtab            strtab            code data         DWARF debug       STABS debug       other             file
 =========  ================= ================= ================= ================= ================= ================= =======================================
1449497856    1417280   0.10%   5616535   0.39%  26035595   1.80%1349819842  93.12%         0   0.00%  66608604   4.60%
Average sizes:
   1884912       1843   0.10%      7303   0.39%     33856   1.80%   1755292  93.12%         0   0.00%     86617   4.60%
aprantl closed this revision.Apr 9 2016, 11:16 AM

r265876