<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2020, at 9:20 AM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="Apple-interchange-newline"><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 13, 2020 at 9:03 AM Vedant Kumar <<a href="mailto:vedant_kumar@apple.com" target="_blank" class="">vedant_kumar@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div dir="ltr" class=""><div dir="ltr" class="">I think I get it now, thanks for explaining!</div><div dir="ltr" class=""><br class=""><blockquote type="cite" class="">On Jan 12, 2020, at 11:44 AM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""><br class=""></blockquote></div><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 10, 2020 at 12:57 PM Vedant Kumar <<a href="mailto:vedant_kumar@apple.com" target="_blank" class="">vedant_kumar@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="">I don't totally follow the proposed encoding change & would appreciate a small example.<div class=""><br class=""></div><div class="">Is the idea to replace e.g. an 'AT_low_pc (<direct address>) + relocation for <direct address>' with an 'AT_low_pc (<indirection into a pool of addresses> + offset)',</div></div></blockquote><div class=""><br class="">With Split DWARF or with DWARFv5 in LLVM at the moment, all addresses are indirected already. So it's:<br class=""><br class="">Replace "AT_low_pc (<indirection into a pool of addresses>)" with an "AT_low_pc (<indirection into a pool of addresses> + offset)".<br class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class="">s.t. the cost of a relocation for the address is paid down the more it's used?</div></div></blockquote><div class=""><br class="">Right - specifically to reduce the pool of addresses down to, ideally, one address per section/indivisible chunk of machine code (per subsection in MachO, for instance) (whereas currently there are many addresses per section)<br class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class="">How do you figure the offset out?</div></div></blockquote><div class=""><br class="">Label difference - same as is done for DW_AT_high_pc today in DWARFv4 and DWARFv5 in LLVM. high_pc currently uses the low_pc addresse to be relative to, in this proposed situation, we'd use a symbol that's in the first bit of debug info in the section (or subsection in MachO). So the low_pc of the subprogram/function, for instance, or if there are two functions in the same section with debug info for both, the low_pc of the first of those functions, etc... <br class=""></div></div></div></div></blockquote><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">If the label difference in a low_pc attribute is relative to the start of a section, could a linker orderfile pass break the dwarf unless it updates the offset?<span class="Apple-converted-space"> </span></div></div></div></blockquote><div class=""><br class="">Nah - terminologically, ELF sections are indivisible - more akin to MachO subsections. ELF files can have multiple sections with the same name (as is used for comdat sections for inline functions, and for -ffunction-sections (roughly equivalent to MachO's "subsections via symbols", as I understand it) (or can use ".text.suffix" naming to give each separate .text section its own name - but the linker strips the suffixes and concatenates all these together into the final linked .text section)<br class=""></div></div></div></div></blockquote><div><br class=""></div><div>I see, so an ELF linker may reorder sections relative to each other, but not the contents of a section. (That matches up with what I've read elsewhere - you'd use -ffunction-sections to reorder function symbols, IIRC.)</div><div><br class=""></div><div>And in this proposal to increase address pool reuse, label differences in a MachO would be relative to the subsection. In Propeller, is basic block reordering done after a .o is emitted? If so, I suppose I don't yet see how the proposed scheme is resilient to this reordering. OTOH if block reordering is done just before the label difference is evaluated, then there shouldn't be any issue.</div><div><span style="caret-color: rgb(0, 0, 0);" class=""> </span></div><blockquote type="cite" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div dir="ltr" class=""><div dir="ltr" class="">Ditto, I suppose, for an intra-function offset when something like propeller is used to reorder basic blocks (I’m thinking of At_call_return_pc now).</div></div></div></blockquote><div class=""><br class="">Yeah - currently the "base address" for each section is determined by the first function with debug info being emitted in that section ( <a href="https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L1787" target="_blank" class="">https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/AsmPrinter/DwarfDebug.cpp#L1787</a> ) - with PROPELLER we'd need to add similar code when function fragments are emitted. (I'm planning to check the PROPELLER work in progress tree soon and do another sanity pass over the debug info emitted to check this is working as intended - in part because this base address selection, coupled with DWARFv5 and maybe with the changes I'm suggesting in this thread (& will commit under flags "soon" (might take me a week or two judging by my review/bug/investigation load right now... *fingers crossed*)) might make PROPELLER less expensive in terms of debug info size, or more expensive relative to the significant improvements this provides)<br class=""></div></div></div></blockquote><div><br class=""></div><div>Thanks for investigating!</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><div class="">Owing to the way MachO debug info distribution works differently & if I understand correctly doesn't need relocations in many cases due to DWARF-aware parsing/linking (& if it does use relocations, I've no knowledge of when/how and how big they are compared to the ELF relocations I've been measuring) it's quite possible MachO would have different tradeoffs in this space.<br class=""></div></div></div></div></blockquote><div><br class=""></div><div>A linked .dSYM (analogous to an ELF .dwp, IIUC) doesn't contain relocations for AT_low_pc or AT_call_return_pc in the simple examples I tried out. We do emit relocations for those attributes in MachO object files (there isn't something analogous to a .dwo on MachO, the debug info just goes into a different set of sections in the .o). My understanding (based on the definition of `macho_relocation_info` in the ld64 sources) is that MachO relocations are 8 bytes in size. It looks like ELF rel/rela relocations are 16/24 bytes in size, but I'm not sure why (perhaps they're more extensible / encode more information).</div><div><br class=""></div><div>Would a vanilla DWARFv4 .dwp (without your patches applied) contain a relocation for each 'AT_low_pc (<direct address>)'?</div><div><br class=""></div><div>vedant</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div dir="ltr" class=""><div dir="ltr" class="">Apologies if this has been answered elsewhere, I suppose there must be a solution for this for At_high_pc to work.<br class=""></div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">vedant</div><div dir="ltr" class=""><br class=""></div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class=""><br class=""></div><div class="">thanks,</div><div class="">vedant<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2020, at 1:33 PM, David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Sounds good all round - I'll commit these two modes, and maybe even the third (given Sony's interest & possible interest in changing their consumer to handle it) of a custom form to eek out the last few bytes from the more direct addr+offset encoding.<br class=""><br class="">I'll follow up here with flag names and revision numbers once they're in.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 8, 2020 at 1:26 PM Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank" class="">paul.robinson@sony.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">On some previous occasion that introduced additional indirection<br class="">(don't remember the details) my debugger people groused about the<br class="">additional performance cost of chasing down data in a different<span class="Apple-converted-space"> </span><br class="">object-file section.  So we (Sony) might be happier with low_pc as<br class="">expressions, than with a ranges-always solution.<br class=""><br class="">But hard to say without data, and getting both modes in at least<br class="">as a temporary thing sounds like a good plan.<br class="">--paulr<br class=""><br class=""><br class="">> -----Original Message-----<br class="">> From:<span class="Apple-converted-space"> </span><a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a><span class="Apple-converted-space"> </span><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>><br class="">> Sent: Wednesday, January 8, 2020 1:49 PM<br class="">> To: David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>><br class="">> Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>>; Jonas Devlieghere<br class="">> <<a href="mailto:jdevlieghere@apple.com" target="_blank" class="">jdevlieghere@apple.com</a>>; Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank" class="">paul.robinson@sony.com</a>>; Eric<br class="">> Christopher <<a href="mailto:echristo@gmail.com" target="_blank" class="">echristo@gmail.com</a>>; Frederic Riss <<a href="mailto:friss@apple.com" target="_blank" class="">friss@apple.com</a>><br class="">> Subject: Re: Increasing address pool reuse/reducing .o file size in<br class="">> DWARFv5<br class="">><span class="Apple-converted-space"> </span><br class="">> I think this sounds like a good plan for Linux. I would like to see the<br class="">> numbers for Darwin (= non-split DWARF) to decide whether we should just<br class="">> make that the default. Eric's suggestion of having this committed as an<br class="">> option first seems like a good step in that direction. If it is an<br class="">> advantage across the board we can remove the option and just make this the<br class="">> default behavior.<br class="">><span class="Apple-converted-space"> </span><br class="">> thanks,<br class="">> adrian<br class="">><span class="Apple-converted-space"> </span><br class="">> > On Dec 30, 2019, at 12:08 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:<br class="">> ><br class="">> > tl;dr: in DWARFv5, using DW_AT_ranges even when the range is contiguous<br class="">> reduces linked, uncompressed debug_addr size for optimized builds by 93%<br class="">> and reduces total .o file size (with compression and split) by 15%. It<br class="">> does grow .dwo file size a bit - DWARFv5, no compression, not split shows<br class="">> the net effect if all bytes are equal: -O3 clang binary grows by 0.4%, -O0<br class="">> clang binary shrinks by 0.1%<br class="">> > Should we enable this strategy by default for DWARFv5, for DWARFv5+Split<br class="">> DWARF, or not by default at all/only under a flag?<br class="">> ><br class="">> ><br class="">> ><br class="">> > So, I've brought this up a few times before - that DWARFv5 does a pretty<br class="">> good job of reducing relocations (& reducing .o file size with Split<br class="">> DWARF) by allowing many uses of addresses to include some kind of<br class="">> address+offset (debug_rnglists and loclists allowing "base_address" then<br class="">> offset_pairs (an improvement over similar functionality in DWARFv4 because<br class="">> the offset pairs can be uleb encoded - so they can be quite compact))<br class="">> ><br class="">> > But one place that DWARFv5 misses to reduce relocations further is<br class="">> direct addresses from debug_info, such as DW_AT_low_pc.<br class="">> ><br class="">> > For a while I've wondered if we could use an extension form for<br class="">> addr+offset, and I prototyped this without an extension attribute, but<br class="">> instead using exprloc. This has slightly higher overhead to express the...<br class="">> expression. (it's 9 bytes in total, could be as few as 5 with a custom<br class="">> form)<br class="">> ><br class="">> > But I had another idea that's more instantly deployable: Why not use<br class="">> DW_AT_ranges even when the range is contiguous? That way the low_pc that<br class="">> previously couldn't use an existing address pool entry + offset, could use<br class="">> the rnglist support for base address.<br class="">> ><br class="">> > The only unnecessary address pool entries that remain that I've found<br class="">> are DW_AT_low_pc for DW_TAG_labels - but there's only a handful of those<br class="">> in most code. So the "ranges everywhere" strategy gets the addresses for<br class="">> optimized clang down from 4758 (v4 address pool used 9923 addresses... )<br class="">> to 342, with about ~4 "extra" addresses for DW_TAG_labels.<br class="">> ><br class="">> > This could also be a bit less costly if DWARFv5 rnglists didn't use a<br class="">> separate offset table (instead encoding the offsets directly in<br class="">> debug_info, rather than using indexes)<br class="">> ><br class="">> > I have patches for both the addr+offset exprloc and for the ranges-<br class="">> always, both with -mllvm flags - do people think they're both worth<br class="">> committing for experimentation? Neither? Default on in some cases (like<br class="">> Split DWARF)?<br class="">> ><br class="">> > Thanks,<br class="">> > - Dave<br class=""><br class=""></blockquote></div>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div></div><span class="">_______________________________________________</span><br class=""><span class="">LLVM Developers mailing list</span><br class=""><span class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a></span><br class=""><span class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span><br class=""></div></blockquote></div></div></blockquote></div></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span></div></blockquote></div><br class=""></body></html>