New patch! Updates tests and adds new test. Tested on Linux and Darwin.<div><br></div><div>The previous patch looked like it worked on linux but didn't (readelf -w on the .o file was fine, but it didn't have relocations so after linking the debug info in the result was wrong). Darwin needs to not have relocations for its string pool entries, while linux needs to have them.</div>

<div><br></div><div>Please review!</div><div><br></div><div>I have not tested this for size improvements in .o files, but I expect it to help there too. If you have a function with an overload or that is templated, the DW_AT_name will be repeated each time. This patch interns those copies. For strings that only occur once, we pay an overhead of 4 bytes (unless the string is 4 bytes, in which case we provide it immediately)</div>

<div><br></div><div>I have however looked at the size reduction of a few small real-world C++ programs at -g -O0 on Linux.</div><div><br></div><div>Before this patch:</div><div>Clang: 804,833,856 bytes</div><div>Program 1: 1,732,799,096 bytes</div>

<div>Program 2: 2,277,486,312 bytes</div><div>Program 3: 1,509,342,448 bytes</div><div><br></div><div>After this patch:</div><div>Clang: 417,182,256 bytes</div><div>Program 1: 935,406,928 bytes</div><div>Program 2: 1,239,206,568 bytes</div>

<div>Program 3: 825,010,104 bytes</div><div><br></div><div>So in my small sample, the new binaries are roughly 50-55% the size after this patch is applied. Before we get too excited, I should also show gcc's numbers:</div>

<div><br></div><div>Clang: 286,878,920 bytes</div><div>Program 1: 694,820,176 bytes</div><div>Program 2: 909,171,592 bytes</div><div>Program 3: 613,554,952 bytes</div><div><br></div><div>which suggests that we have further room to improve.</div>

<div><br></div><div>Nick</div><div><br><div class="gmail_quote">On 25 October 2011 01:11, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca">nicholas@mxc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Updated patch, this one works on Darwin now too.<br>
<br>
I have tested this patch on Darwin in both -m32 and -m64 modes. The difference from the previous patch is that I now use DIEDelta to compute a section offset against the string pool, instead of DIELabel to refer to the string directly (hey, it worked for me on Linux).<br>


<br>
Please review!<br>
<br>
Nick<br>
<br>
Nick Lewycky wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
DWARF allows string to be specified in one of two ways, either by<br>
writing them literally (DW_FORM_string) or by including a pointer into<br>
the .debug_str section and putting the NUL-terminated string there.<br>
<br>
The attached patch removes the Form argument from CompileUnit::AddString<br>
and changes addString to emit either a DIEString or a DIELabel depending<br>
on how long the string is. If the string would fit in 4 bytes in the<br>
direct encoding, do that. Otherwise, hoist it out into .debug_str so<br>
that it can be interned.<br>
<br>
This is a major issue on linux where the linker does not turn direct<br>
strings into indirect strings, but does merge the string tables. On<br>
Darwin, the linker will turn direct strings into indirect strings as<br>
needed. However, this change should probably be enabled on all platforms<br>
as it generally makes .o files smaller.<br>
<br>
Please review! The one thing I don't like about this patch is that we<br>
emit the bytes (via .ascii) and then emit the NUL (via. ".zero 1"). The<br>
alternatives I see are either to create a copy of the string, or to<br>
create a new emitBytesWithNUL API in MCStreamer.<br>
<br>
Nick<br>
<br>
PS. If this patch doesn't work on Darwin out-of-the-box, please try one<br>
thing for me: comment out the change to DIELabel::SizeOf (adding a case<br>
for DW_FORM_strp), and let me know whether that fixes things.<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</blockquote>
<br>
</blockquote></div><br></div>