<div dir="ltr">Hi David,<div><br></div><div>Thanks for the patch. Yes, I am interested in removing cycles in debug info MDNodes. One of the reasons that we create new copies of MDNodes in the linked module is cycles.</div>
<div>But I may not get to this soon.</div><div><br></div><div>Manman</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 1:41 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">From a thread with Adrian on llvm-commits I looked a little at cases where DwarfCompileUnit's getOrCreateContextDIE's "fallback to return the CU" didn't fire when a CU DIE was required (ie: when the "getDIE" call actually found the CU before the fallback happened)<br>

<br>This seems unnecessary, and any case where we do this (where a metadata node has a non-null context DIE pointing to the CU) is just wasted space. By ensuring we always use null to refer to the CU we'll reduce cycles and metadata nodes in LTO situations allowing the nodes to be re-used across CUs in LTO cases.<br>

<br>I've attached the CLang patch to do this, but I don't want to commit this until the LLVM test cases have been cleaned up (the easiest way to find these test cases would be to add an assert in CompileUnit::getORCreateContextDIE. Changing this:<br>

<br><div>  if (DIE *ContextDIE = getDIE(Context))</div><div>    return ContextDIE;<br><br>to this:</div><div><br></div><div>  if (DIE *ContextDIE = getDIE(Context)) {</div><div>    assert(ContextDIE != CUDie);<br><div>    return ContextDIE;<br>

  }<br><br>Then finding all the test cases that fail and null out any context fields that refer to the CU, thus relying on the fallback instead.<br><br>Since we're not working on LTO right now, cleaning up those test cases (20-30, it's not a lot but more than I have time for) isn't something I can do right now but seemed like it might be interesting to you. And I figured you'd be able to see if this helps size much, whereas I've not been looking at/analyzing LTO size costs.</div>

<br></div><div><br></div></div>
</blockquote></div><br></div>