<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 30, 2021 at 7:16 PM chuanqi.xcq <<a href="mailto:yedeng.yd@linux.alibaba.com">yedeng.yd@linux.alibaba.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Hi Jeremy and David,</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><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></blockquote><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><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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 style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><blockquote style="margin-right:0px;margin-top:0px;margin-bottom:0px"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">------------------------------------------------------------------</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">From:David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Send Time:2021年3月31日(星期三) 00:24</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">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 style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">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 style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">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:14px;color:rgb(0,0,0)"><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></blockquote><div><br></div></div></blockquote></div></div>