<div class="__aliyun_email_body_block"><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">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.</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;">Overall, thanks for your guys look into this.</div><div  style="clear:both;"><br ></div><div  style="clear:both;">Thanks,</div><div  style="clear:both;">Chuanqi</div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">[1] https://reviews.llvm.org/D86185</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">[2] https://reviews.llvm.org/D96531</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">[3] https://reviews.llvm.org/rG7e6c87ee045497ee0b6b7e55e54921b274e8a9f2</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">[4] https://reviews.llvm.org/D92127</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">[5] https://reviews.llvm.org/rG4318028cd2d7633a0cdeb0b5d4d2ed81fab87864</span></div><blockquote  style="margin-right:0;margin-top:0;margin-bottom:0;"><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">------------------------------------------------------------------</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">From:David Blaikie <dblaikie@gmail.com></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Send Time:2021年3月31日(星期三) 10:28</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">To:chuanqi.xcq <yedeng.yd@linux.alibaba.com></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Cc:Jeremy Morse <jeremy.morse.llvm@gmail.com>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Subject:Re: [llvm-dev] Why the binary size in trunk are smaller significantly?</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div ><div ><br ></div><br ><div  class="gmail_quote"><div  class="gmail_attr">On Tue, Mar 30, 2021 at 7:16 PM chuanqi.xcq <<a  href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>> wrote:<br ></div><div ><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Hi Jeremy and David,</span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;">     The most significant reduction comes from the section `.debug_loc` and `.debug_info` section.</div><div  style="clear:both;">     The size of `.debug_info` reduced about 14% and the size of of `.debug_loc` reduced to even 69%!</div></div><div ><br ></div><div >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.<br ><br >But I could be wrong - it is a pretty big swing, for sure.<br ><br >- Dave</div><div > </div><div ><div  style="clear:both;"><br ></div><div  style="clear:both;">     I would try the patches in the link. </div><div  style="clear:both;"><br ></div><div  style="clear:both;">Thanks,</div><div  style="clear:both;">Chuanqi</div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">------------------------------------------------------------------</span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">From:David Blaikie <<a  href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Send Time:2021年3月31日(星期三) 00:24</span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">To:Jeremy Morse <<a  href="mailto:jeremy.morse.llvm@gmail.com" target="_blank">jeremy.morse.llvm@gmail.com</a>></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Cc:chuanqi.xcq <<a  href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>>; <a  href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a> <<a  href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Subject:Re: [llvm-dev] Why the binary size in trunk are smaller significantly?</span></div><div  style="clear:both;"><span  class=" __aliyun_node_has_color" style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div >Yep, I'd be curious to see more data - comparisons of sections sizes (<a  href="https://github.com/google/bloaty" target="_blank">Bloaty</a> 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.</div><br ><div  class="gmail_quote"><div  class="gmail_attr">On Tue, Mar 30, 2021 at 3:33 AM Jeremy Morse <<a  href="mailto:jeremy.morse.llvm@gmail.com" target="_blank">jeremy.morse.llvm@gmail.com</a>> wrote:<br ></div>Hi Chuanqi,<br ><br >
On Tue, Mar 30, 2021 at 9:47 AM chuanqi.xcq via llvm-dev<br >
<<a  href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br >
> 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.<br >
><br >
> 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.<br ><br >
Interesting -- which sections reduce in size between llvm-11 and<br >
trunk? Assuming you're using ELF/DWARF binaries, `readelf -W -S` will<br >
give you sections and sizes.<br ><br >
Since llvm-11 branched, there were some patches [0] that improved how<br >
variable locations are represented in DWARF, I've seen some binaries<br >
where that reduced file size by 10%. That would be reflected in the<br >
.debug_loc section. There's also the constructor homing flag, passed<br >
to clang with "-Xclang -fuse-ctor-homing", I'm not sure whether it's<br >
on by default in trunk. That would show a significant reduction in the<br >
.debug_info section.<br ><br >
[0] <a  href="https://reviews.llvm.org/rG0b5a8050ea39355a3876cc6bba9383d91e224e1f" target="_blank">https://reviews.llvm.org/rG0b5a8050ea39355a3876cc6bba9383d91e224e1f</a><br ><br >
--<br >
Thanks,<br >
Jeremy<br ></div><div ><br ></div></div></div></div></blockquote><div ><br ></div></div>