-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Description
Example code,
module mod1
integer :: a = 1, b = 2
end module
subroutine sub1()
use mod1, foo => a
print *, foo, b
end subroutine
subroutine sub2()
use mod1, only : bar => b
print *, bar
end subroutine
With flang, no DW_TAG_variable is generated for foo and bar.
Proposed solution is to insert metadata nodes of DIImportedEntity with tag: field to be DW_TAG_imported_declaration and name: field to be tha variable's name, e.g.
!23 = !DIImportedEntity(tag: DW_TAG_imported_declaration, entity: !13, scope: !22, file: !3, line: 5, name: "foo")
!30 = !DIImportedEntity(tag: DW_TAG_imported_declaration, entity: !16, scope: !29, file: !3, line: 10, name: "bar")
By looking into the DWARF from gfortran, with or without only, the scope could be different though, either belong to the subprogram or the imported module.
<1><2f>: Abbrev Number: 4 (DW_TAG_module)
<30> DW_AT_name : (indirect string, offset: 0x10): mod1
...
<1><6f>: Abbrev Number: 6 (DW_TAG_subprogram)
<70> DW_AT_external : 1
<70> DW_AT_name : (indirect string, offset: 0xef): sub1
...
<2><91>: Abbrev Number: 7 (DW_TAG_imported_module)
...
<95> DW_AT_import : <0x2f> [Abbrev Number: 4 (DW_TAG_module)]
<3><99>: Abbrev Number: 2 (DW_TAG_imported_declaration)
...
<9c> DW_AT_name : foo
<a0> DW_AT_import : <0x3b> [Abbrev Number: 1 (DW_TAG_variable)]
...
<1><a6>: Abbrev Number: 8 (DW_TAG_subprogram)
<a7> DW_AT_external : 1
<a7> DW_AT_name : (indirect string, offset: 0xf4): sub2
...
<2><c4>: Abbrev Number: 2 (DW_TAG_imported_declaration)
...
<c7> DW_AT_name : bar
<cb> DW_AT_import : <0x51> [Abbrev Number: 1 (DW_TAG_variable)]