[PATCH] D97311: [WIP][DebugInfo] Introduce DIConstant metadata for representing named constants

Sourabh Singh Tomar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 23 11:33:18 PST 2021


SouraVX created this revision.
SouraVX added reviewers: probinson, aprantl, dblaikie, jini.susan.george, alok, schweitz, kiranchandramohan.
Herald added a reviewer: deadalnix.
Herald added subscribers: dexonsmith, hiraditya.
Herald added a reviewer: sscalpone.
SouraVX requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

LLVM Debug metadata lacks the capability of representing named constants.
Languages such as Fortran has named constants, and code written in Fortran
extensively uses Constants, hence there's an inherent need to provide
debug information support for Constants to aid Fortran programs debugging.

This patch introduces `DIConstant`, which at the moment, will serve the needs of
Fortran frontends.

This is still a WIP state patch, as it create the skeleton structure(relevant DWARF) which
can be debugged in GDB.

Problem yet to be resolved:

  !DIConstant(name: "module_constant", scope: !2, file: !3, line: 4, type: !14, value: 24)
  
  Value inside last field is interpreted as `unsigned 24 and signed -8 in APInt`, so at the
  emission point which check signedness based on type(here integer) and
  chooses `-8`.
  
  DW_TAG_constant
     DW_AT_name    ("module_constant")
     DW_AT_external        (true)
     DW_AT_const_value     (-8)

Testing:

- check-llvm
- Regression test added (Marked XFAIL at the moment, for demonstrating

the problem highlighted above) .

TODO:

- Define DIBuilder interface and use it to add unit tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97311

Files:
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/include/llvm/IR/Metadata.def
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Verifier.cpp
  llvm/test/Assembler/diconstant.ll
  llvm/test/Bindings/llvm-c/debug_info.ll
  llvm/test/DebugInfo/fortran-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97311.325848.patch
Type: text/x-patch
Size: 37658 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210223/c14bd952/attachment.bin>


More information about the llvm-commits mailing list