| Issue |
180836
|
| Summary |
[flang][debug] Incorrect module variable scope when applying "use mod, only : alias => var"
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
jiel-nv
|
Code example,
```
module mod1
integer :: a = 1
integer :: b = 2
end module
subroutine sub1()
use mod1, only : acopy = > a
end subroutine
```
`flang` generated DWARF for `sub1` wraps the declaration inside a module import, making ALL module variables visible.
```
<1><6b>: Abbrev Number: 5 (DW_TAG_subprogram)
<6c> DW_AT_low_pc : 0x0
<74> DW_AT_high_pc : 0x6
<78> DW_AT_frame_base : 1 byte block: 56 (DW_OP_reg6 (rbp))
<7a> DW_AT_linkage_name: (indirect string, offset: 0xba): sub1_
<7e> DW_AT_name : (indirect string, offset: 0xc0): sub1
<82> DW_AT_decl_file : 1
<83> DW_AT_decl_line : 6
<84> DW_AT_external : 1
<2><84>: Abbrev Number: 6 (DW_TAG_imported_module)
<85> DW_AT_decl_file : 1
<86> DW_AT_decl_line : 1
<87> DW_AT_import : <0x2a> [Abbrev Number: 2 (DW_TAG_module)]
<3><8b>: Abbrev Number: 7 (DW_TAG_imported_declaration)
<8c> DW_AT_decl_file : 1
<8d> DW_AT_decl_line : 1
<8e> DW_AT_import : <0x31> [Abbrev Number: 3 (DW_TAG_variable)]
<92> DW_AT_name : (indirect string, offset: 0xb4): acopy
```
`gfortran` generated DWARF for `sub1` only contains the imported declaration, which is as expected.
```
<1><6f>: Abbrev Number: 5 (DW_TAG_subprogram)
<70> DW_AT_external : 1
<70> DW_AT_name : (indirect string, offset: 0x43): sub1
<74> DW_AT_decl_file : 1
<75> DW_AT_decl_line : 6
<76> DW_AT_linkage_name: (indirect string, offset: 0x15): sub1_
<7a> DW_AT_low_pc : 0x0
<82> DW_AT_high_pc : 0x7
<8a> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<8c> DW_AT_GNU_all_call_sites: 1
<2><8c>: Abbrev Number: 6 (DW_TAG_imported_declaration)
<8d> DW_AT_decl_file : 1
<8e> DW_AT_decl_line : 7
<8f> DW_AT_name : (indirect string, offset: 0x35): acopy
<93> DW_AT_import : <0x39> [Abbrev Number: 3 (DW_TAG_variable)]
```
The problematic LLVM IR emitted by flang is as below, `DW_TAG_imported_declaration` is incorrectly nested inside `DW_TAG_imported_module`,
```
!17 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !13, entity: !2, file: !3, line: 1, elements: !18)
!18 = !{!19}
!19 = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: "acopy", scope: !13, entity: !1, file: !3, line: 1)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs