[PATCH] Add a DIExternalTypeRef debug metadata node to the IR.

Adrian Prantl aprantl at apple.com
Fri May 8 15:49:33 PDT 2015


> On May 8, 2015, at 3:02 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Fri, May 8, 2015 at 2:55 PM, Adrian Prantl <aprantl at apple.com <mailto:aprantl at apple.com>> wrote:
> 
>> On May 8, 2015, at 2:42 PM, David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com>> wrote:
>> 
>> 
>> 
>> On Fri, May 8, 2015 at 2:38 PM, Adrian Prantl <aprantl at apple.com <mailto:aprantl at apple.com>> wrote:
>> 
>> > On May 8, 2015, at 1:00 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com <mailto:dexonsmith at apple.com>> wrote:
>> >
>> >
>> >> On 2015 May 8, at 15:32, David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com>> wrote:
>> >>
>> >>
>> >>
>> >> On Fri, May 8, 2015 at 11:18 AM, Adrian Prantl <aprantl at apple.com <mailto:aprantl at apple.com>> wrote:
>> >> Hi dexonsmith, dblaikie, echristo,
>> >>
>> >> This adds a DIExternalTypeRef debug metadata node to the IR that is meant to be emitted by Clang when referring to a type that is defined in a .pcm file. DIExternalTypeRef is a child of DICompositeTypeBase because it shares common traits such as the unique identifier.
>> >>
>> >> Could this be an attribute to the DIClassType/StructureType? (to emit the currently needed type unit references, we still should know the correct class/structure type tag) LLVM already knows to hash the ref identifier (mangled name) for the type unit identifier.
>> 
>> Note that DIExternalTypeRef also knows the tag.
>> 
>> OK. Though I'm still unclear on the advantage of this over just making this essentially another kind of type declaration... (heck, I've wondered if we could just do this by default: if type units are enabled and we're emitting a type declaration for a type with a the ref identifier, just emit it as a type unit
> 
> Agreed, but as you say:
> 
>> - but I guess that won't solve the issue of using module debug info but not using type units generally (would still need the flag to describe that this type needs to be a type ref, not a plain declaration))
> 
> Exactly — plus, there are non-composite kinds of types that are worth representing as an external reference. The best example is maybe the typedef type std::string.
> 
> I can't imagine it's worth putting typedefs in module debug info. (certainly not while type units are the foundation of them - and we still haven't fully hammered out why you're proposing doing two different things (one with type units, one without) - I'd like to keep things consistent with the standard features, if possible) the overhead of type units is high enough that doesn't seem worthwhile.

Ok, I think I can do without typedefs.
> 
> Once we're dealing with the fully general referencable debug info (Bag O DWARF) we'll need to reference more than types anyway (such as subprograms).
> 
> I'd rather not implement a bunch of half-generalizations now that seem like the enable not very valuable things today while still not providing the full generality we'll want in the end anyway.
> It'd be nice to just do the basic type unit based functionality (which itself should require very few changes to the LLVM metadata format)

We need exactly 2 changes for this to work: http://reviews.llvm.org/D9488 <http://reviews.llvm.org/D9488> (dwo id / Skeleton CUs), and some form of this review. I think your proposal of doing this as a flag on DICompositeType is reasonable as it allows us to capture what is arguably the most important special case.

What about adding a FlagExternalTypeRef to DebugInfoFlags.def so we can distinguish it from FlagFwdDecl?

> and then consider the few extensions that can help module AST loading for LLDB

There’s only one (IR) change necessary for this (http://reviews.llvm.org/D9614 <http://reviews.llvm.org/D9614>).

> (granted, I realize this stuff takes time to review, etc, so I get doing it in parallel - but it does mean I'm dealing with a lot of different pieces from you & don't have quite enough context for any of them (because it seems like quite a few changes have been made (admittedly, some necessary) from the original discussions we had months ago)) & then the full generality/glorious future with Bag O DWARF related capabilities.

I very much appreciate the time and energy you are investing in reviewing all of these patches. Please let me know where I can provide more context, I’ll also do my best to add more about how pieces are going to be used when posting the next set of patches.

thanks!
adrian

> 
> - David
>  
> 
> -- adrian
> 
>>  
>> >
>> > I think they should be separate for now.  When we have an
>> > `identifier:` field in `DICompositeType` we use the
>> > string-based `DITypeRef`s instead of direct pointers.  I don't
>> > imagine there's any value in adding that indirection for these.
>> 
>> It would make lookups slower, but otherwise it would be harmless.
>> 
>> > (Although, this makes me wonder about an LTO scenario.  Imagine you
>> > have two translation units, and they both use a type identified by
>> > (e.g.) "my-type".  One of them pulled the type in from a module
>> > and has a `DIExternalTypeRef`, while the other translation unit
>> > didn't use modules and has a `DICompositeType`.  What should the
>> > debug info look like?  Is it okay if we end up with both?  If not,
>> > which one should win?
>> 
>> This is a scenario that can only happen in C++. For maximum space efficiency you would want the external type ref to win or you will end up with two copies of the type (which isn’t otherwise harmful). If you are are using dsymutil, it will still unique the two copies.
>> 
>> >  Will these new nodes show up in the
>> > `retainedType:` list?)
>> 
>> They will not show up in the retained types list.
>> 
>> >
>> > Another couple of questions to decide whether to make a new node:
>> >
>> > 1. Will the backend logic be essentially the same for the two, or
>> >    would we have disjoint handling?
>> 
>> There is different backend handling for LLDB and GDB.
>> 
>> > 2. Is this a reasonable target for a 'scope:' field?  (If not, I
>> >    think they should be distinct.)
>> 
>> We could attach the Skeleton compile unit but there is no real need for it. Making them distinct sounds fine for me.
>> 
>> -- adrian
>> >
>> >
>> >>
>> >> - David
>> >>
>> >>
>> >> The idea how this is going to be used is that the frontend will discover that a type originates from an AST file and instead of and constructing a full DIType (and thus deserializing the type from the AST) it creates a DIExternalTypeRef with the tag type, mangled name and the .pcm file. The backend then can emit this as a split-DWARF-style forward declaration using DW_FORM_ref_sig8 (GDB) or as a string reference (LLDB) + and accelerator table entry.
>> >>
>> >> REPOSITORY
>> >>  rL LLVM
>> >>
>> >> http://reviews.llvm.org/D9612 <http://reviews.llvm.org/D9612>
>> >>
>> >> Files:
>> >>  include/llvm/Bitcode/LLVMBitCodes.h
>> >>  include/llvm/IR/DIBuilder.h
>> >>  include/llvm/IR/DebugInfoMetadata.h
>> >>  include/llvm/IR/Metadata.def
>> >>  include/llvm/IR/Metadata.h
>> >>  lib/AsmParser/LLParser.cpp
>> >>  lib/Bitcode/Reader/BitcodeReader.cpp
>> >>  lib/Bitcode/Writer/BitcodeWriter.cpp
>> >>  lib/IR/AsmWriter.cpp
>> >>  lib/IR/DIBuilder.cpp
>> >>  lib/IR/DebugInfoMetadata.cpp
>> >>  lib/IR/LLVMContextImpl.h
>> >>  lib/IR/Verifier.cpp
>> >>  test/Assembler/DIExternalTypeRef.ll
>> >>
>> >> EMAIL PREFERENCES
>> >>  http://reviews.llvm.org/settings/panel/emailpreferences/ <http://reviews.llvm.org/settings/panel/emailpreferences/>
>> >>
>> >
>> 
>> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150508/20d4b5ca/attachment.html>


More information about the llvm-commits mailing list