DWARF allows string to be specified in one of two ways, either by writing them literally (DW_FORM_string) or by including a pointer into the .debug_str section and putting the NUL-terminated string there.<div><br></div><div>

The attached patch removes the Form argument from CompileUnit::AddString and changes addString to emit either a DIEString or a DIELabel depending on how long the string is. If the string would fit in 4 bytes in the direct encoding, do that. Otherwise, hoist it out into .debug_str so that it can be interned.</div>

<div><br></div><div>This is a major issue on linux where the linker does not turn direct strings into indirect strings, but does merge the string tables. On Darwin, the linker will turn direct strings into indirect strings as needed. However, this change should probably be enabled on all platforms as it generally makes .o files smaller.</div>

<div><br></div><div>Please review! The one thing I don't like about this patch is that we emit the bytes (via .ascii) and then emit the NUL (via. ".zero 1"). The alternatives I see are either to create a copy of the string, or to create a new emitBytesWithNUL API in MCStreamer.</div>

<div><br></div><div>Nick</div><div><br></div><div>PS. If this patch doesn't work on Darwin out-of-the-box, please try one thing for me: comment out the change to DIELabel::SizeOf (adding a case for DW_FORM_strp), and let me know whether that fixes things.</div>

<div><br></div>