<div dir="ltr"><div dir="ltr">You can differentiate dead function descriptions from others on most platforms by checking if the low_pc == 0. If 0 is a valid instruction address on your architecture, you can use an lld feature to set a more authoritative/unambiguous tombstone value for dead code addresses, passing something like:<br><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><i> -z 'dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe'
</i><i> -z 'dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe'
</i><i> -z 'dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff'<br></i></pre></div>to the linker.<br><br>As for reducing debug info size by omitting debug info descriptions of dead code - Apple/MachO's dsymutil does this, and I believe Alexey Lapshin is working on trying to get similar behavior into lld, possibly (or as a post-link tool).<br><br>There's also the possibility of using comdats to make the linker's job easier - I think there might be ways to structure the DWARF into chunks that could be deduplicated and dropped naturally by a linker's existing comdat support, but I haven't fully prototyped it. I think there was a thread a while back with JHenderson and others discussing this possibility further.<br><br>- Dave<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 29, 2021 at 12:50 PM Youssefi, Anna via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</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 lang="EN-US">
<div class="gmail-m_-4019873380599080817WordSection1">
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I was wondering if there are any plans to separate debug information into distinct sections accordingly when the compiler flags -ffunction-sections and/or -fdata-sections are used.  If an unreferenced function is removed from the link,
 it makes no sense for its associated debug information to still be included.  As we rely on the debug information for stack usage analysis, we wind up displaying stack usage statistics for unreferenced functions that were eliminated from the link if debug
 information for any other referenced functions is in the same debug section.  It seems that others have run into this problem previously so I wanted to check whether there are any plans to change the behavior.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Anna Youssefi<u></u><u></u></p>
<p class="MsoNormal">Texas Instruments, Codegen group<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>