[llvm-dev] [DebugInfo]: Representing constants in debug-info

via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 10 05:53:07 PST 2021


I don't see any use of DW_TAG_constant in the LLVM tree, except in the DWARFLinker, which isn't what you need.

Most things not needed by C-family languages aren't supported, because to date nobody has needed them (or if they did, they implemented the support downstream).  The closest similar thing would be enumerator constants; you could probably imitate what's done for those fairly easily.
--paulr

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Tomar, Sourabh Singh via llvm-dev
Sent: Wednesday, February 10, 2021 12:54 AM
To: llvm-dev <llvm-dev at lists.llvm.org>
Cc: George, Jini Susan <JiniSusan.George at amd.com>; Chen, Chih-Ping <chih-ping.chen at intel.com>; Sharma, Alok Kumar <AlokKumar.Sharma at amd.com>
Subject: [llvm-dev] [DebugInfo]: Representing constants in debug-info


[AMD Public Use]

Hi Everyone,

Is there a way of representing **constants** in LLVM debug-info ? Languages such as FORTRAN has constants

i.e, consider the following Fortran snippet
[...]
Module foo
Integer, parameter :: bar = 200 ! Constant
End module foo
[...]

A front-end may choose to emit as Global Constant in LLVM IR as:
[...]
@bar.. = internal constant i32 200

A naïve attempt to represent it as GlobalVariable(or constant) as
[...]
!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression(DW_OP_consts, 200))
!8 = distinct !DIGlobalVariable(name: "bar", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true)

This will materialize in DWARF as:
0x0000004a:     DW_TAG_variable
                  DW_AT_name    ("bar")
                  ...
                 DW_AT_location        (DW_OP_addr 0x2007d4, DW_OP_consts +200)  // This is incorrect, pointing to data section
[...]

Gfortran is representing this as: **DW_TAG_constant**
0x00000055:     **DW_TAG_constant**
                  DW_AT_name    ("bar")
                 ...
                  DW_AT_type    (0x0000006a "const integer(kind=4)")
                  DW_AT_external        (true)
                  DW_AT_const_value     (0xc8)

Do we have Metadata analog of (DW_TAG_constant) ? I think the primary question here is to how represent this ?

Any inputs appreciated!

Thanks.. much!
Sourabh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210210/aa753a21/attachment.html>


More information about the llvm-dev mailing list