[llvm-dev] Why the binary size in trunk are smaller significantly?

chuanqi.xcq via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 31 00:48:40 PDT 2021


From my experiments, the two patches contributes a lot `[Cloning] Fix to cloning DISubprograms`[1] and `TransformUtils: Fix metadata handling in CloneModule`[2]. And I also suspected for `DebugInfo: Deduplicate addresses in debug_addr`[3], `[LiveDebugVariables] Strip all debug instructions from nodebug functions`[4] and `DebugInfo: Add a DWARF FORM extension for addrx+offset references to reduce relocations`[5] from their titles. But experiements shows that they contribute little for my case. I guess there would still be spaces to reduce the debug size from the perspective of debug infomation.

Overall, thanks for your guys look into this.

Thanks,
Chuanqi


[1] https://reviews.llvm.org/D86185
[2] https://reviews.llvm.org/D96531
[3] https://reviews.llvm.org/rG7e6c87ee045497ee0b6b7e55e54921b274e8a9f2
[4] https://reviews.llvm.org/D92127
[5] https://reviews.llvm.org/rG4318028cd2d7633a0cdeb0b5d4d2ed81fab87864
------------------------------------------------------------------
From:David Blaikie <dblaikie at gmail.com>
Send Time:2021年3月31日(星期三) 10:28
To:chuanqi.xcq <yedeng.yd at linux.alibaba.com>
Cc:Jeremy Morse <jeremy.morse.llvm at gmail.com>; llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
Subject:Re: [llvm-dev] Why the binary size in trunk are smaller significantly?



On Tue, Mar 30, 2021 at 7:16 PM chuanqi.xcq <yedeng.yd at linux.alibaba.com> wrote:
Hi Jeremy and David,

     The most significant reduction comes from the section `.debug_loc` and `.debug_info` section.
     The size of `.debug_info` reduced about 14% and the size of of `.debug_loc` reduced to even 69%!

Surprises me a bit, but yeah, that could be debug info related, or unrelated - optimizations might make fewer variable locations because we've lost track of more variables so there are no locations - or locations might be better tracked so they're more contiguously described (so less small slices of variable locations - each slice having some overhead in its description)... but hard to say. llvm-dwarfdump --statistics might be insightful as to whether it's improvement in locations or not. But I'd make an educated guess that this probably isn't reflective of any bugs and is just roughly expected change from optimization changes and maybe debug info location improvements.

But I could be wrong - it is a pretty big swing, for sure.

- Dave

     I would try the patches in the link. 

Thanks,
Chuanqi



------------------------------------------------------------------
From:David Blaikie <dblaikie at gmail.com>
Send Time:2021年3月31日(星期三) 00:24
To:Jeremy Morse <jeremy.morse.llvm at gmail.com>
Cc:chuanqi.xcq <yedeng.yd at linux.alibaba.com>; llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
Subject:Re: [llvm-dev] Why the binary size in trunk are smaller significantly?

Yep, I'd be curious to see more data - comparisons of sections sizes (Bloaty is a handy tool to make comparisons simpler (though for a one off might not be worth the hassle of going and downloading/building it/etc)) & any work that could be done isolating/reducing the test case (hopefully enough that it can be shared) and verifying what differences might exist between the two compilations if there's anything other than the compiler version.
On Tue, Mar 30, 2021 at 3:33 AM Jeremy Morse <jeremy.morse.llvm at gmail.com> wrote:
Hi Chuanqi,

 On Tue, Mar 30, 2021 at 9:47 AM chuanqi.xcq via llvm-dev
 <llvm-dev at lists.llvm.org> wrote:
 > In a private code bases, I find that the binary size produced in llvm-11 is 60M while the size produced in trunk is 51M.
 >
 > I tried to find the patch who made this change in git log or in phabricator by keywords like `reduce`, 'size' or 'binary'. But I find nothing.

 Interesting -- which sections reduce in size between llvm-11 and
 trunk? Assuming you're using ELF/DWARF binaries, `readelf -W -S` will
 give you sections and sizes.

 Since llvm-11 branched, there were some patches [0] that improved how
 variable locations are represented in DWARF, I've seen some binaries
 where that reduced file size by 10%. That would be reflected in the
 .debug_loc section. There's also the constructor homing flag, passed
 to clang with "-Xclang -fuse-ctor-homing", I'm not sure whether it's
 on by default in trunk. That would show a significant reduction in the
 .debug_info section.

 [0] https://reviews.llvm.org/rG0b5a8050ea39355a3876cc6bba9383d91e224e1f

 --
 Thanks,
 Jeremy


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210331/8ce1977b/attachment.html>


More information about the llvm-dev mailing list