<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 11, 2016 at 3:26 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"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Mon, Jul 11, 2016 at 1:46 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.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"><div class="gmail_extra"><div class="gmail_quote"><span>On Fri, Jul 8, 2016 at 2:35 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<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="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Does this make debug info larger by emitting forward declarations for every type, even when they aren't necessary? (this would certainly happen if we did this in DWARF emission - so just wondering how it compares). Any idea how much of a penalty that is for CV size?</div></div></div></div></blockquote><div><br></div></span><div>CodeView always has forward declarations for all record types, and they are used to avoid cycles in the type graph:<br></div><div><a href="http://llvm.org/docs/SourceLevelDebugging.html#format-background" target="_blank">http://llvm.org/docs/SourceLevelDebugging.html#format-background</a></div></div></div></div></blockquote><div><br></div></div></div><div>Even in cases where there are no cycles? (perhaps that's such a small number of cases (only C structs*, I would think, but I don't know the format well enough/at all) that the benefit isn't worth the engineering effort to elide them in these cases)<br></div></div></div></div></blockquote><div><br></div><div>Yes, there's always a forward declaration, and it's important that all type records refer to the forward declaration. Otherwise cross-TU type merging will fail on cases like these:</div><div><br></div><div>// TU1</div><div>struct A;</div><div>struct B { A *a; }; // the A* type record will point to a fwd decl of A.</div><div>static B b;</div><div><br></div><div>// TU2</div><div>struct A {};</div><div>struct B { A *a; };  // could use the complete A type in the A* type record, but we don't</div><div>static B b;</div><div><br></div><div>We want B's field list record to be bitwise identical in TU1 and TU2, or we waste space in the PDB and the user might see two B types in the debugger. That means using the same type index for A in the A* pointer type record. We get that by using the forward declaration.</div></div></div></div>