-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Description
Code example,
module mod1
integer :: a = 1
integer :: b = 2
end module
subroutine sub1()
use mod1, only : a
end subroutine
When using debugger to inspect variable from inside sub1, only a should be visible, but currently flang is giving the whole module imported to sub1.
!2 = !DIModule(scope: !4, name: "mod1", file: !3, line: 1)
!11 = distinct !DISubprogram(name: "sub1", linkageName: "sub1_", scope: !3, file: !3, line: 6, type: !12, scopeLine: 6, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !14)
!15 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !11, entity: !2, file: !3, line: 1)
The solution should be straight forward,
(1) change the tag: field of DIImportedEntity from DW_TAG_imported_module to DW_TAG_imported_declaration;
(2) change the entity: field of DIImportedEntity from referencing the module to refencing the variable;
!1 = distinct !DIGlobalVariable(name: "a", linkageName: "_QMmod1Ea", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
!2 = !DIModule(scope: !4, name: "mod1", file: !3, line: 1)
!11 = distinct !DISubprogram(name: "sub1", linkageName: "sub1_", scope: !3, file: !3, line: 6, type: !12, scopeLine: 6, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4, retainedNodes: !14)
!15 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !11, entity: !1, file: !3, line: 1)