[llvm] r273443 - [codeview] Defer emission of all referenced complete records

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 15:39:21 PDT 2016


On Mon, Jul 11, 2016 at 3:26 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Mon, Jul 11, 2016 at 1:46 PM, Reid Kleckner <rnk at google.com> wrote:
>
>> On Fri, Jul 8, 2016 at 2:35 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>>
>>> 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?
>>>
>>
>> CodeView always has forward declarations for all record types, and they
>> are used to avoid cycles in the type graph:
>> http://llvm.org/docs/SourceLevelDebugging.html#format-background
>>
>
> 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)
>

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:

// TU1
struct A;
struct B { A *a; }; // the A* type record will point to a fwd decl of A.
static B b;

// TU2
struct A {};
struct B { A *a; };  // could use the complete A type in the A* type
record, but we don't
static B b;

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160711/eac0d353/attachment.html>


More information about the llvm-commits mailing list