<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 8, 2015, at 2:42 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, May 8, 2015 at 2:38 PM, Adrian Prantl <span dir="ltr" class=""><<a href="mailto:aprantl@apple.com" target="_blank" class="">aprantl@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
> On May 8, 2015, at 1:00 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" class="">dexonsmith@apple.com</a>> wrote:<br class="">
><br class="">
><br class="">
>> On 2015 May 8, at 15:32, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class="">
>><br class="">
>><br class="">
>><br class="">
>> On Fri, May 8, 2015 at 11:18 AM, Adrian Prantl <<a href="mailto:aprantl@apple.com" class="">aprantl@apple.com</a>> wrote:<br class="">
>> Hi dexonsmith, dblaikie, echristo,<br class="">
>><br class="">
>> 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.<br class="">
>><br class="">
>> 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.<br class="">
<br class="">
</span>Note that DIExternalTypeRef also knows the tag.<br class=""></blockquote><div class=""><br class="">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</div></div></div></div></div></blockquote><div><br class=""></div><div>Agreed, but as you say:</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> - 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))<br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>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.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">><br class="">
> I think they should be separate for now.  When we have an<br class="">
> `identifier:` field in `DICompositeType` we use the<br class="">
> string-based `DITypeRef`s instead of direct pointers.  I don't<br class="">
> imagine there's any value in adding that indirection for these.<br class="">
<br class="">
</span>It would make lookups slower, but otherwise it would be harmless.<br class="">
<span class=""><br class="">
> (Although, this makes me wonder about an LTO scenario.  Imagine you<br class="">
> have two translation units, and they both use a type identified by<br class="">
> (e.g.) "my-type".  One of them pulled the type in from a module<br class="">
> and has a `DIExternalTypeRef`, while the other translation unit<br class="">
> didn't use modules and has a `DICompositeType`.  What should the<br class="">
> debug info look like?  Is it okay if we end up with both?  If not,<br class="">
> which one should win?<br class="">
<br class="">
</span>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.<br class="">
<span class=""><br class="">
>  Will these new nodes show up in the<br class="">
> `retainedType:` list?)<br class="">
<br class="">
</span>They will not show up in the retained types list.<br class="">
<span class=""><br class="">
><br class="">
> Another couple of questions to decide whether to make a new node:<br class="">
><br class="">
> 1. Will the backend logic be essentially the same for the two, or<br class="">
>    would we have disjoint handling?<br class="">
<br class="">
</span>There is different backend handling for LLDB and GDB.<br class="">
<span class=""><br class="">
> 2. Is this a reasonable target for a 'scope:' field?  (If not, I<br class="">
>    think they should be distinct.)<br class="">
<br class="">
</span>We could attach the Skeleton compile unit but there is no real need for it. Making them distinct sounds fine for me.<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
-- adrian<br class="">
</font></span><div class="HOEnZb"><div class="h5">><br class="">
><br class="">
>><br class="">
>> - David<br class="">
>><br class="">
>><br class="">
>> 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.<br class="">
>><br class="">
>> REPOSITORY<br class="">
>>  rL LLVM<br class="">
>><br class="">
>> <a href="http://reviews.llvm.org/D9612" target="_blank" class="">http://reviews.llvm.org/D9612</a><br class="">
>><br class="">
>> Files:<br class="">
>>  include/llvm/Bitcode/LLVMBitCodes.h<br class="">
>>  include/llvm/IR/DIBuilder.h<br class="">
>>  include/llvm/IR/DebugInfoMetadata.h<br class="">
>>  include/llvm/IR/Metadata.def<br class="">
>>  include/llvm/IR/Metadata.h<br class="">
>>  lib/AsmParser/LLParser.cpp<br class="">
>>  lib/Bitcode/Reader/BitcodeReader.cpp<br class="">
>>  lib/Bitcode/Writer/BitcodeWriter.cpp<br class="">
>>  lib/IR/AsmWriter.cpp<br class="">
>>  lib/IR/DIBuilder.cpp<br class="">
>>  lib/IR/DebugInfoMetadata.cpp<br class="">
>>  lib/IR/LLVMContextImpl.h<br class="">
>>  lib/IR/Verifier.cpp<br class="">
>>  test/Assembler/DIExternalTypeRef.ll<br class="">
>><br class="">
>> EMAIL PREFERENCES<br class="">
>>  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank" class="">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br class="">
>><br class="">
><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>