[cfe-dev] Should "imports" list in DICompileUnit have duplication of DIImportedEntity?

Adrian Prantl via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 2 11:37:12 PST 2016


> On Mar 2, 2016, at 12:59 AM, Aboud, Amjad <amjad.aboud at intel.com> wrote:
> 
> Hi,
> It looks like Clang FE does not treat imported entities list (“imports”) as a set that has no duplication.
> 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).

It looks like we get into this situation easily since DIBuilder::createImportedModule will add every namespace mentioned in a using directive.

> Should "imports" list in DICompileUnit have duplication of DIImportedEntity?
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.
> Do you think we should fix Clang to assure the "imports" list is a unique set?

I would also take a look at the DIBuilder interface — it may or may not be better to unique them there.
>  
> Notice that there is no added value to have the same entity duplicated!
>  

thanks for noticing!

adrian

> Thanks,
> Amjad
>  
>  
> The example (using the attached files):
>  
> Command-line: clang -cc1 -S -emit-llvm -o - -debug-info-kind=limited TestIM.cpp
> !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)
> !1 = !DIFile(filename: " <stdin>", directory: "\\")
> !2 = !{}
> !3 = !{!4, !4}  <----------------------------  Bug: same entity appears twice in the imported entities list!
> !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !7, line: 8)
> !5 = !DINamespace(name: "Y", scope: null, file: !6, line: 7)
> 
> 
> Command-line: clang -cc1 -S -emit-obj -o - -debug-info-kind=limited TestIM.cpp | llvm-dwarfdump.exe -debug-dump=info –
> 0x0000000b: DW_TAG_compile_unit [1] *
>               DW_AT_producer [DW_FORM_strp]     ( .debug_str[0x00000000] = "clang version 3.9.0 (trunk 259349) (llvm/trunk 259357)")
>               DW_AT_language [DW_FORM_data2]    (DW_LANG_C_plus_plus)
>               DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = " <stdin>")
>               DW_AT_stmt_list [DW_FORM_sec_offset]      (0x00000000)
>               DW_AT_comp_dir [DW_FORM_strp]     ( .debug_str[0x0000004e] = " \\ ")
>  
> 0x0000001e:   DW_TAG_namespace [2] *
>                 DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000074] = "Y")
>                 DW_AT_decl_file [DW_FORM_data1] ("TestIM.h")
>                 DW_AT_decl_line [DW_FORM_data1] (7)
>  
> 0x00000025:     DW_TAG_imported_declaration [3]
>                   DW_AT_decl_file [DW_FORM_data1]       ("TestIM.h")
>                   DW_AT_decl_line [DW_FORM_data1]       (8)
>                   DW_AT_import [DW_FORM_ref4]   (cu + 0x003b => {0x0000003b})
>  
> 0x0000002c:     DW_TAG_imported_declaration [3]           <----------------------------  duplication of 0x00000025
>                   DW_AT_decl_file [DW_FORM_data1]       ("TestIM.h")
>                   DW_AT_decl_line [DW_FORM_data1]       (8)
>                   DW_AT_import [DW_FORM_ref4]   (cu + 0x003b => {0x0000003b})
>  
> 0x00000033:     NULL
>  
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> 
> <TestIM.H><TestIM.CPP>




More information about the cfe-dev mailing list