<div dir="ltr">Yeah, I can't see any reason we'd benefit from them either.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 2, 2016 at 11:37 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Mar 2, 2016, at 12:59 AM, Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com">amjad.aboud@intel.com</a>> wrote:<br>
><br>
> Hi,<br>
> It looks like Clang FE does not treat imported entities list (“imports”) as a set that has no duplication.<br>
> In the below simple example, imported entities list contains a duplication for same DIImportedEntity, which will end up having duplication of this imported entity in the dwarf debug info section (see below).<br>
<br>
</span>It looks like we get into this situation easily since DIBuilder::createImportedModule will add every namespace mentioned in a using directive.<br>
<span class=""><br>
> Should "imports" list in DICompileUnit have duplication of DIImportedEntity?<br>
</span>Right now I can’t think of a good reason where this would be useful. And if it is useful, we can always use distinct MDNodes to work around the problem.<br>
<span class="">> Do you think we should fix Clang to assure the "imports" list is a unique set?<br>
<br>
</span>I would also take a look at the DIBuilder interface — it may or may not be better to unique them there.<br>
<span class="">><br>
> Notice that there is no added value to have the same entity duplicated!<br>
><br>
<br>
</span>thanks for noticing!<br>
<br>
adrian<br>
<div><div class="h5"><br>
> Thanks,<br>
> Amjad<br>
><br>
><br>
> The example (using the attached files):<br>
><br>
> Command-line: clang -cc1 -S -emit-llvm -o - -debug-info-kind=limited TestIM.cpp<br>
> !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 261634) (llvm/trunk 261633)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, imports: !3)<br>
> !1 = !DIFile(filename: " <stdin>", directory: "\\")<br>
> !2 = !{}<br>
> !3 = !{!4, !4}  <----------------------------  Bug: same entity appears twice in the imported entities list!<br>
> !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !7, line: 8)<br>
> !5 = !DINamespace(name: "Y", scope: null, file: !6, line: 7)<br>
><br>
><br>
> Command-line: clang -cc1 -S -emit-obj -o - -debug-info-kind=limited TestIM.cpp | llvm-dwarfdump.exe -debug-dump=info –<br>
> 0x0000000b: DW_TAG_compile_unit [1] *<br>
>               DW_AT_producer [DW_FORM_strp]     ( .debug_str[0x00000000] = "clang version 3.9.0 (trunk 259349) (llvm/trunk 259357)")<br>
>               DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)<br>
>               DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = " <stdin>")<br>
>               DW_AT_stmt_list [DW_FORM_sec_offset]      (0x00000000)<br>
>               DW_AT_comp_dir [DW_FORM_strp]     ( .debug_str[0x0000004e] = " \\ ")<br>
><br>
> 0x0000001e:   DW_TAG_namespace [2] *<br>
>                 DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000074] = "Y")<br>
>                 DW_AT_decl_file [DW_FORM_data1] ("TestIM.h")<br>
>                 DW_AT_decl_line [DW_FORM_data1] (7)<br>
><br>
> 0x00000025:     DW_TAG_imported_declaration [3]<br>
>                   DW_AT_decl_file [DW_FORM_data1]       ("TestIM.h")<br>
>                   DW_AT_decl_line [DW_FORM_data1]       (8)<br>
>                   DW_AT_import [DW_FORM_ref4]   (cu + 0x003b => {0x0000003b})<br>
><br>
> 0x0000002c:     DW_TAG_imported_declaration [3]           <----------------------------  duplication of 0x00000025<br>
>                   DW_AT_decl_file [DW_FORM_data1]       ("TestIM.h")<br>
>                   DW_AT_decl_line [DW_FORM_data1]       (8)<br>
>                   DW_AT_import [DW_FORM_ref4]   (cu + 0x003b => {0x0000003b})<br>
><br>
> 0x00000033:     NULL<br>
><br>
> ---------------------------------------------------------------------<br>
> Intel Israel (74) Limited<br>
><br>
> This e-mail and any attachments may contain confidential material for<br>
> the sole use of the intended recipient(s). Any review or distribution<br>
> by others is strictly prohibited. If you are not the intended<br>
> recipient, please contact the sender and delete all copies.<br>
><br>
</div></div>> <TestIM.H><TestIM.CPP><br>
<br>
</blockquote></div><br></div>