[PATCH] D108553: [DebugInfo] Emit DW_TAG_namelist and DW_TAG_namelist_item for fortran namelist variable

Bhuvan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 23 06:41:01 PDT 2021


bhuvanendrakumarn created this revision.
bhuvanendrakumarn added reviewers: aprantl, dblaikie, alok, jini.susan.george.
bhuvanendrakumarn added a project: debug-info.
Herald added subscribers: dexonsmith, ormris, jfb, hiraditya.
Herald added a reviewer: sscalpone.
bhuvanendrakumarn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch emits DW_TAG_namelist and DW_TAG_namelist_item for fortran namelist variables. Namelist in fortran is basically group of variables. Already Metadata is created for each of the namelist items or variables, we just need to create MDList of these items and use the DICompositeType (with TAG: DW_TAG_namelist). Gfortran supports this fortran feature already. Flang is enhanced to support this feature and GDB also enhanced to support this. Both flang and GDB changes will up streamed soon.

Sample fortran program, IR, dwarf info are shared below.

Sample program :

program main

  integer :: a, b
  namelist /nml/ a, b
   
  a = 10
  b = 20
  Write(*,nml)

end program main

LLVM IR:

!20 = !DILocalVariable(scope: !15, name: "a", file: !3, line: 6, type: !19)
. . .
!22 = !DILocalVariable(scope: !15, name: "b", file: !3, line: 7, type: !19)
. . .
!24 = !{ !20, !22 }
!25 = !DICompositeType(tag: DW_TAG_namelist, file: !3, scope: !15, name: "nml", elements: !24)

dwarfdump :

. . .
0x000000b4:     DW_TAG_variable [10]

  DW_AT_name [DW_FORM_string]   ("a")
  DW_AT_decl_file [DW_FORM_data1]       ("/dir/namelist.f90")
  DW_AT_decl_line [DW_FORM_data1]       (20)
  DW_AT_type [DW_FORM_ref4]     (cu + 0x006d => {0x0000006d} "integer(kind=4)")
  DW_AT_declaration [DW_FORM_flag_present]      (true)
  DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg -20)
   

0x000000c0:     DW_TAG_variable [10]

  DW_AT_name [DW_FORM_string]   ("b")
  DW_AT_decl_file [DW_FORM_data1]       ("/dir/namelist.f90")
  DW_AT_decl_line [DW_FORM_data1]       (20)
  DW_AT_type [DW_FORM_ref4]     (cu + 0x006d => {0x0000006d} "integer(kind=4)")
  DW_AT_declaration [DW_FORM_flag_present]      (true)
  DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg -24)

. . .
0x000000dd:     DW_TAG_namelist [12] *

  DW_AT_name [DW_FORM_string]   ("nml")
   

0x000000e2:       DW_TAG_namelist_item [9]

  DW_AT_namelist_item [DW_FORM_ref4]  (cu + 0x00b4 => {0x000000b4})
   

0x000000e7:       DW_TAG_namelist_item [9]

  DW_AT_namelist_item [DW_FORM_ref4]  (cu + 0x00c0 => {0x000000c0})
   

0x000000ec:       NULL


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108553

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/DebugInfo/X86/namelist1.ll
  llvm/test/DebugInfo/X86/namelist2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108553.368090.patch
Type: text/x-patch
Size: 17807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210823/ffd495cb/attachment.bin>


More information about the llvm-commits mailing list