<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.msipheader87abd423, li.msipheader87abd423, div.msipheader87abd423
        {mso-style-name:msipheader87abd423;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:322316408;
        mso-list-template-ids:1548495772;}
@list l1
        {mso-list-id:918290697;
        mso-list-type:hybrid;
        mso-list-template-ids:-1146040462 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l1:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l2
        {mso-list-id:1478721122;
        mso-list-template-ids:-1766049580;}
@list l3
        {mso-list-id:1775785308;
        mso-list-type:hybrid;
        mso-list-template-ids:1084664930 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l3:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l3:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l3:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l3:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="msipheader87abd423" style="margin:0in"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#317100">[AMD Public Use]</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Paul,<o:p></o:p></p>
<p class="MsoNormal">Thanks for the hints for a possible implementation by mimicking something close to Enumerations. I noticed 2 problems doing so:<o:p></o:p></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l3 level1 lfo3">Enumerators are integers, while a constant can be of any type(at least basic types provided by the base language).<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l3 level1 lfo3">Restricting Scope of a Constant, Scoping concerns with Enumerator as depicted in
<a href="https://bugs.llvm.org/show_bug.cgi?id=49153">https://bugs.llvm.org/show_bug.cgi?id=49153</a><o:p></o:p></li></ol>
<p class="MsoNormal" style="margin-left:.25in"><o:p> </o:p></p>
<p class="MsoNormal">We did some digging in LLVM history, seems like there were some attempts for bringing DW_TAG_constant back in 2010;<br>
However things are not clear with respect to overall support, as a result it was dropped.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Second last commit cites some GDB related concerns(back in 2010) for removal of DW_TAG_constant from LLVM.<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal">commit b407bb2789e0c1daea1b7d7e896e6a600e408cf0<o:p></o:p></p>
<p class="MsoNormal">Author: Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>><o:p></o:p></p>
<p class="MsoNormal">Date:   Mon Feb 9 22:48:04 2015 +0000<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    DebugInfo: Remove DW_TAG_constant<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    Remove handling for DW_TAG_constant.  We started producing it in<o:p></o:p></p>
<p class="MsoNormal">    r110656, but reverted that in r110876 without dropping the support.<o:p></o:p></p>
<p class="MsoNormal">    Finish the job.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    llvm-svn: 228623<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">commit 4d597e82684d462bc98f2ff934e37d3c5e38a0c9<o:p></o:p></p>
<p class="MsoNormal">Author: Devang Patel <<a href="mailto:dpatel@apple.com">dpatel@apple.com</a>><o:p></o:p></p>
<p class="MsoNormal">Date:   Wed Aug 11 23:17:54 2010 +0000<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    Even if a variable has constant value all the time, it is still a variable in gdb's eyes.<o:p></o:p></p>
<p class="MsoNormal">    Tested by scope.exp in gdb testsuite.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    llvm-svn: 110876<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">commit b219746c80be195e914d6f620427217818476ba8<o:p></o:p></p>
<p class="MsoNormal">Author: Devang Patel <<a href="mailto:dpatel@apple.com">dpatel@apple.com</a>><o:p></o:p></p>
<p class="MsoNormal">Date:   Tue Aug 10 07:11:13 2010 +0000<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    Handle TAG_constant for integers.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">    llvm-svn: 110656<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Now, that GDB has support for DW_TAG_constant is pretty decent. So I wanted to take this opportunity to define a new DIConstant metadata which will eventually materialize as DW_TAG_constant in DWARF.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Supporting arguments with respect to this:<o:p></o:p></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo6">Languages such as Fortran and the new Frontend Flang(now part of LLVM) can utilize this for producing debug-info.<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0in;mso-list:l1 level1 lfo6">Other languages that have named constant and there potential front-ends(living down-stream or not part of LLVM)  should be able utilize this too.<o:p></o:p></li></ol>
<p class="MsoNormal"><br>
Thanks ..much!<o:p></o:p></p>
<p class="MsoNormal">Sourabh.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> paul.robinson@sony.com <paul.robinson@sony.com>
<br>
<b>Sent:</b> Wednesday, February 10, 2021 7:23 PM<br>
<b>To:</b> Tomar, Sourabh Singh <SourabhSingh.Tomar@amd.com>; llvm-dev@lists.llvm.org<br>
<b>Cc:</b> George, Jini Susan <JiniSusan.George@amd.com>; chih-ping.chen@intel.com; Sharma, Alok Kumar <AlokKumar.Sharma@amd.com><br>
<b>Subject:</b> RE: [DebugInfo]: Representing constants in debug-info<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[CAUTION: External Email] <o:p></o:p></p>
<div>
<p class="MsoNormal">I don’t see any use of DW_TAG_constant in the LLVM tree, except in the DWARFLinker, which isn’t what you need.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal">--paulr<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Tomar, Sourabh Singh via llvm-dev<br>
<b>Sent:</b> Wednesday, February 10, 2021 12:54 AM<br>
<b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
<b>Cc:</b> George, Jini Susan <<a href="mailto:JiniSusan.George@amd.com">JiniSusan.George@amd.com</a>>; Chen, Chih-Ping <<a href="mailto:chih-ping.chen@intel.com">chih-ping.chen@intel.com</a>>; Sharma, Alok Kumar <<a href="mailto:AlokKumar.Sharma@amd.com">AlokKumar.Sharma@amd.com</a>><br>
<b>Subject:</b> [llvm-dev] [DebugInfo]: Representing constants in debug-info<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="msipheader87abd423" style="margin:0in"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#317100">[AMD Public Use]</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Everyone,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is there a way of representing **constants** in LLVM debug-info ? Languages such as FORTRAN has constants<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">i.e, consider the following Fortran snippet<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal">Module foo<o:p></o:p></p>
<p class="MsoNormal">Integer, parameter :: bar = 200 ! Constant<o:p></o:p></p>
<p class="MsoNormal">End module foo<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A front-end may choose to emit as Global Constant in LLVM IR as:<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal">@bar.. = internal constant i32 200<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">A naïve attempt to represent it as GlobalVariable(or constant) as<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal">!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression(DW_OP_consts, 200))<o:p></o:p></p>
<p class="MsoNormal">!8 = distinct !DIGlobalVariable(name: "bar", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This will materialize in DWARF as:<o:p></o:p></p>
<p class="MsoNormal">0x0000004a:     DW_TAG_variable<o:p></o:p></p>
<p class="MsoNormal">                  DW_AT_name    ("bar")<o:p></o:p></p>
<p class="MsoNormal">                  …<o:p></o:p></p>
<p class="MsoNormal">                 DW_AT_location        (DW_OP_addr 0x2007d4, DW_OP_consts +200)  // This is incorrect, pointing to data section<o:p></o:p></p>
<p class="MsoNormal">[…]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Gfortran is representing this as: **DW_TAG_constant**<br>
0x00000055:     **<b>DW_TAG_constant</b>**<o:p></o:p></p>
<p class="MsoNormal">                  DW_AT_name    ("bar")<o:p></o:p></p>
<p class="MsoNormal">                 …<o:p></o:p></p>
<p class="MsoNormal">                  DW_AT_type    (0x0000006a "const integer(kind=4)")<o:p></o:p></p>
<p class="MsoNormal">                  DW_AT_external        (true)<o:p></o:p></p>
<p class="MsoNormal">                  DW_AT_const_value     (0xc8)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Do we have Metadata analog of (DW_TAG_constant) ? I think the primary question here is to how represent this ?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any inputs appreciated!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks.. much!<br>
Sourabh.<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>