<div dir="ltr"><font size="2">I think you'd need at least two changes - one in the frontend to add linkage names and then the backend to use them.<br><br>Clang change:</font><br><br><div><font face="monospace" size="2">diff --git lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.cpp</font></div><div><font face="monospace" size="2">index c9aa04815f..f392a24e09 100644</font></div><div><font face="monospace" size="2">--- lib/CodeGen/CGDebugInfo.cpp</font></div><div><font face="monospace" size="2">+++ lib/CodeGen/CGDebugInfo.cpp</font></div><div><font face="monospace" size="2">@@ -2867,7 +2867,7 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,</font></div><div><font face="monospace" size="2"> !CGM.getCodeGenOpts().EmitGcovNotes &&</font></div><div><font face="monospace" size="2"> !CGM.getCodeGenOpts().DebugInfoForProfiling &&</font></div><div><font face="monospace" size="2"> DebugKind <= codegenoptions::DebugLineTablesOnly))</font></div><div><font face="monospace" size="2">- LinkageName = StringRef();</font></div><div><font face="monospace" size="2">+ ; // LinkageName = StringRef();</font></div><div><font face="monospace" size="2"> </font></div><div><font face="monospace" size="2"> if (DebugKind >= codegenoptions::LimitedDebugInfo) {</font></div><div><font size="2"><font face="monospace"> if (const NamespaceDecl *NSDecl =</font><br><br>LLVM change:<br><br></font><div style="font-family:monospace"><font size="2">diff --git lib/CodeGen/AsmPrinter/DwarfUnit.cpp lib/CodeGen/AsmPrinter/DwarfUnit.cpp</font></div><div style="font-family:monospace"><font size="2">index 784a1d512c1..c9e4e2ecdac 100644</font></div><div style="font-family:monospace"><font size="2">--- lib/CodeGen/AsmPrinter/DwarfUnit.cpp</font></div><div style="font-family:monospace"><font size="2">+++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp</font></div><div style="font-family:monospace"><font size="2">@@ -1194,7 +1194,9 @@ void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,</font></div><div style="font-family:monospace"><font size="2"> return;</font></div><div style="font-family:monospace"><font size="2"> </font></div><div style="font-family:monospace"><font size="2"> // Constructors and operators for anonymous aggregates do not have names.</font></div><div style="font-family:monospace"><font size="2">- if (!SP->getName().empty())</font></div><div style="font-family:monospace"><font size="2">+ if (SkipSPAttributes && !SP->getLinkageName().empty())</font></div><div style="font-family:monospace"><font size="2">+ addLinkageName(SPDie, SP->getLinkageName());</font></div><div style="font-family:monospace"><font size="2">+ else if (!SP->getName().empty())</font></div><div style="font-family:monospace"><font size="2"> addString(SPDie, dwarf::DW_AT_name, SP->getName());</font></div><div style="font-family:monospace"><font size="2"> </font></div><div><font size="2" style="font-family:monospace"> if (!SkipSPSourceLocation)<br></font><br>Obviously this is just a hack to test - and I might've missed other necessary changes, but at least a simple test case seems to do what I'd want:<br><br><div><font face="monospace">0x0000000b: DW_TAG_compile_unit [1] *</font></div><div><font face="monospace"> ...</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">0x0000002a: DW_TAG_subprogram [2] </font></div><div><font face="monospace"> DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x0000006d] = "_Z2f2v")</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">0x0000002f: DW_TAG_subprogram [3] *</font></div><div><font face="monospace"> ...</font></div><div><font face="monospace"> DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00000074] = "_Z2f3v")</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">0x00000040: DW_TAG_inlined_subroutine [4] </font></div><div><font face="monospace"> DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x002a => {0x0000002a} "_Z2f2v")</font></div><div><font face="monospace"> ...</font></div><div><br>(built from:<br><br><div><font face="monospace">void f1();</font></div><div><font face="monospace">__attribute__((always_inline)) void f2() {</font></div><div><font face="monospace"> f1();</font></div><div><font face="monospace">}</font></div><div><font face="monospace">void f3() {</font></div><div><font face="monospace"> f2();</font></div><div><font face="monospace">}</font><br>)<br><br>Might break non-gmlt (though not in any way that's readily apparent to me), might break backwards compatible (taking existing frontend gmlt-like IR and building it with this /should/ do the right thing, falling back to the DW_AT_name in the absence of DW_AT_linkage_name, but untested, etc), etc.<br><br></div></div></div></div><div class="gmail_quote"><div dir="ltr">On Wed, Aug 2, 2017 at 3:03 PM Nico Weber via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 2, 2017 at 4:48 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">There's a bunch of custom logic in lib/CodeGen/AsmPrinter/DwarfDebug.cpp to gate the emission of linkage names, including a hidden option called -dwarf-linkage-names that you may need to enable.</div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Thanks. I changed that flag to default to on (in addition to my clang-side change) but that didn't seem to make a difference:</div><div><br></div><div><div>Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp</div><div>===================================================================</div><div>--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp<span class="m_7223914400775900729m_754656979549678153gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>(revision 309585)</div><div>+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp<span class="m_7223914400775900729m_754656979549678153gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>(working copy)</div><div>@@ -115,7 +115,7 @@</div><div> clEnumValN(AllLinkageNames, "All", "All"),</div><div> clEnumValN(AbstractLinkageNames, "Abstract",</div><div> "Abstract subprograms")),</div><div>- cl::init(DefaultLinkageNames));</div><div>+ cl::init(AllLinkageNames));</div><div> </div><div> static const char *const DWARFGroupName = "dwarf";</div><div> static const char *const DWARFGroupDescription = "DWARF Emission";</div></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></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 style="word-wrap:break-word"><span class="m_7223914400775900729m_754656979549678153gmail-HOEnZb"><font color="#888888"><div><br></div><div>-- adrian</div></font></span><div><div class="m_7223914400775900729m_754656979549678153gmail-h5"><div><br><div><blockquote type="cite"><div>On Aug 2, 2017, at 1:44 PM, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> wrote:</div><br class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422Apple-interchange-newline"><div><div dir="ltr">I'm happy to collect data if someone can tell me how to get the compiler to always emit DW_AT_linkage_name. My non-working attempt was this:<div><br></div><div><div>Index: lib/CodeGen/CGDebugInfo.cpp</div><div>===================================================================</div><div>--- lib/CodeGen/CGDebugInfo.cpp<span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>(revision 309585)</div><div>+++ lib/CodeGen/CGDebugInfo.cpp<span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>(working copy)</div><div>@@ -2861,12 +2861,8 @@</div><div> Flags |= llvm::DINode::FlagPrototyped;</div><div> }</div><div> // No need to replicate the linkage name if it isn't different from the</div><div>- // subprogram name, no need to have it at all unless coverage is enabled or</div><div>- // debug is set to more than just line tables or extra debug info is needed.</div><div>- if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&</div><div>- !CGM.getCodeGenOpts().EmitGcovNotes &&</div><div>- !CGM.getCodeGenOpts().DebugInfoForProfiling &&</div><div>- DebugKind <= codegenoptions::DebugLineTablesOnly))</div><div>+ // subprogram name.</div><div>+ if (LinkageName == Name)</div><div> LinkageName = StringRef();</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 5:12 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span><div dir="ltr">On Mon, Jul 31, 2017 at 10:30 AM David Blaikie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-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 dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Jul 31, 2017 at 10:19 AM Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 29, 2015 at 4:03 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-"><blockquote type="cite"><div>On Apr 29, 2015, at 12:25 PM, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> wrote:</div><br class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-m_-9000920310424982279Apple-interchange-newline"><div><div dir="ltr">Hi,<div><br></div><div>the motivation for -gline-tables-only was to make debug info much smaller, but still include enough to get usable stack frames [1]. We recently tried using it in Chromium and discovered that the stack frames aren't all that usable: Function parameters disappear, as do function namespaces.</div><div><br></div><div>Are there any concerns about adding a mode to -gline-tables-only (or a second flag -gline-tables-full, or similar) that includes function parameter info and namespace info but still omits most debug info?</div></div></div></blockquote><div><br></div></span><div>I’m not convinced that the resulting debug info will dramatically smaller than the full debug info. The largest bit of the debug info is the type information if we are going to emit function parameters that will probably pull in the majority of the types in the program.</div></div></div></blockquote><div><br></div><div>Reviving this a few years later: Just letting clang emit DW_AT_linkage_name in -g1 would give us qualified stacks, and wouldn't require serializing any debug info for types from what I understand. gcc does emit DW_AT_linkage_name in -g1.</div><div><br>We're currently using fdebug-info-for-profiling + -g1 on Android which does give us DW_AT_linkage_name but also a bunch of other stuff, and we had to know about the flag. If -g1 just emitted DW_AT_linkage_name by default, that'd be pretty useful while also being pretty cheap size-wise.</div><div><br></div><div>Opinions?</div></div></div></div></blockquote></div></div><div dir="ltr"><div class="gmail_quote"><div><br>Would be great to have a prototype & numbers to back up/quantify the "pretty cheap size-wise" (& good to look at object size as well as final executable size). & Alexey's no longer working on this stuff - so probably add kcc or eugenis maybe? That was the original motivation for -gmlt (symbolized stacks in asan) so they're probably more sensitive to the size costs.<br><br></div></div></div></blockquote><div><br></div></span><div>IIRC mostly it's a lot of strings in the output. That said, I agree that it would be very useful and we should probably contemplate it as just "part of the expense of C++ and stack traces" here. Be good to get numbers first so we know what we're getting ourselves into though.</div><div><br></div><div>-eric</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"><span><div dir="ltr"><div class="gmail_quote"><div>- Dave<br> </div></div></div><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><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 style="word-wrap:break-word"><div><span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-"><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>(Background: We rely on dsym files to let our crash server symbolize crash dumps we get from the wild. dsymutil uses debug info, but it apparently crashes if debug info is > 4GB. </div></div></div></blockquote><div><br></div></span><div>The problem here is that neither llvm nor dsymutil understand the 64-bit DWARF format. Note that the llvm-dsymutil that is being developed will be able to do ODR-based type uniquing for C++, which should also provide enough savings to make this go well under the 4GB mark. </div><span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-"><br><blockquote type="cite"><div><div dir="ltr"><div>We hit that recently. So we started using -gline-tables-only, but now all our stacks are close to unusable, even though the motivation for gline-tables-only was to still have usable stacks. We can't easily use symbol names as they get stripped very early in our pipeline, and changing that is apparently involved.)</div></div></div></blockquote><div><br></div><div><br></div></span><span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-HOEnZb"><font color="#888888"><div>-- adrian</div></font></span><span class="m_7223914400775900729m_754656979549678153gmail-m_-7144819687070226422m_-4265792129872045252m_1924920045927647317m_-4674907118823140343gmail-"><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Thanks,</div><div>Nico</div><div><br></div><div><br></div><div>1: <a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120423/056674.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120423/056674.html</a></div></div>
</div></blockquote></span></div><br></div></blockquote></div><br></div></div>
</blockquote></div></div></span>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>
</blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>