<div dir="ltr">from the llvm::Function you can get a DISubprogram (Function's getSubprogram), from there you could get the DISubprogram's type (getType) and then poke around at the elements of the type, I guess.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 26, 2021 at 10:39 PM Bella V <<a href="mailto:bellavistaghome@gmail.com">bellavistaghome@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you for the clarification. How do we access <span style="color:rgb(0,128,128);background-color:rgb(255,255,254);font-family:"Consolas, "">DICompositeType: line numbers </span>from <span style="color:rgb(0,128,128);background-color:rgb(255,255,254);font-family:"Consolas, "">Function &F</span><span style="color:rgb(0,128,128);background-color:rgb(255,255,254);font-family:"Consolas, ""> </span>or<span style="color:rgb(0,128,128);background-color:rgb(255,255,254);font-family:"Consolas, ""> Module &M.</span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 26, 2021 at 9:43 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">the location of composite types isn't stored in a DILocation - it's stored in the 'file'/'line' attributes of the DICompositeType (similarly, the members have a 'file' and 'line' attribute).<br><br>See for instance line 39 of the LLVM IR in <a href="https://godbolt.org/z/o3oce5" target="_blank">https://godbolt.org/z/o3oce5</a> :<br><br><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Consolas, ""><div><span style="color:rgb(244,71,71)">!12</span> <span style="color:rgb(244,71,71)">=</span> <span style="color:rgb(86,156,214)">distinct</span> !<span style="color:rgb(61,201,176)">DICompositeType</span><span style="color:rgb(220,220,220)">(</span><span style="color:rgb(61,201,176)">tag</span>: <span style="color:rgb(61,201,176)">DW_TAG_structure_type</span>, <span style="color:rgb(61,201,176)">name</span>: <span style="color:rgb(206,145,120)">"Foo"</span>, <span style="color:rgb(61,201,176)">file</span>: !<span style="color:rgb(181,206,168)">8</span>, <span style="color:rgb(61,201,176)">line</span>: <span style="color:rgb(181,206,168)">1</span>, <span style="color:rgb(61,201,176)">size</span>: <span style="color:rgb(181,206,168)">32</span>, <span style="color:rgb(61,201,176)">flags</span>: <span style="color:rgb(61,201,176)">DIFlagTypePassByValue</span>, <span style="color:rgb(61,201,176)">elements</span>: !<span style="color:rgb(181,206,168)">13</span>, <span style="color:rgb(61,201,176)">identifier</span>: <span style="color:rgb(206,145,120)">"_ZTS3Foo"</span><span style="color:rgb(220,220,220)">)</span></div><div><span style="color:rgb(244,71,71)"></span></div></div></div><br>Note the 'file:' and 'line: fields there. (the file field refers to !8 which is <span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(244,71,71)">!8</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Consolas, ""> </span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(244,71,71)">=</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Consolas, ""> </span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(244,71,71)">!</span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(86,156,214)">DIFile</span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(220,220,220)">(</span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(61,201,176)">filename</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Consolas, "">: </span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(206,145,120)">"./example.cpp"</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Consolas, "">, </span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(61,201,176)">directory</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Consolas, "">: </span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(206,145,120)">"/home/ce"</span><span style="background-color:rgb(30,30,30);font-family:"Consolas, ";color:rgb(220,220,220)">))</span><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 26, 2021 at 5:15 PM Bella V <<a href="mailto:bellavistaghome@gmail.com" target="_blank">bellavistaghome@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for the answer. <div><div>struct Foo<br>{int x;};</div><div><br></div><div>Void bar() {<br></div><div>struct Foo f;<br></div><div>f.x = 1;<br></div><div>}</div><div><br></div><div>I'm trying to access the DILocation for DICompositeType (Foo), that is the Source Location for struct Foo and struct members. Any pointers. </div><div><br></div></div><div>Regards.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 17, 2021 at 11:20 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Not sure I understand the question - llvm.dbg.declare can be<br>
queried/examined/etc through the usual LLVM IR APIs, yes - it's an<br>
intrinsic call, with operands, etc. It's a DbgVariableIntrinsic (<br>
<a href="https://llvm.org/doxygen/classllvm_1_1DbgVariableIntrinsic.html" rel="noreferrer" target="_blank">https://llvm.org/doxygen/classllvm_1_1DbgVariableIntrinsic.html</a> ) you<br>
can interrogate for information.<br>
<br>
On Fri, Jan 15, 2021 at 7:17 PM Bella V <<a href="mailto:bellavistaghome@gmail.com" target="_blank">bellavistaghome@gmail.com</a>> wrote:<br>
><br>
> Thank you. Also Is there a pragmatically way to access the metadata info for local variables within the llvm.dbg.declare.<br>
> ( llvm::Value does not have local variables).<br>
><br>
> On Tue, Jan 12, 2021 at 1:55 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> You'd have to get IR from somewhere that has attached debug info - such as clang -g<br>
>><br>
>> On Tue, Jan 12, 2021 at 1:22 PM Bella V <<a href="mailto:bellavistaghome@gmail.com" target="_blank">bellavistaghome@gmail.com</a>> wrote:<br>
>>><br>
>>> Do we have to initially attach some metadata to the Value? Because in function pass, when I do F.getAllMetadata(MDs), i do not see any metadata appending to MDS.<br>
>>> F.hasMetadata() also returns false. What would be the way to get debugLoc in these scenario?<br>
>>><br>
>>> Thanks and Regards.<br>
>>><br>
>>> On Mon, Jan 11, 2021 at 6:31 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Mon, Jan 11, 2021 at 4:33 PM Ayush Mittal via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>> wrote:<br>
>>>>><br>
>>>>> Hello Cfe Users,<br>
>>>>><br>
>>>>> Could you please point to an effective way to get Source Location details from an IR code.<br>
>>>>> From the documentation, I think this could be a way:<br>
>>>>> Function Pass-> LLVM Value-> MDN->DILocation-> Source Location.<br>
>>>><br>
>>>><br>
>>>> Yep, that's about it (I mean, you can do it in a pass, or not - but  yes, find an llvm::Value and get the debugLoc from that)<br>
>>>><br>
>>>>><br>
>>>>> Please include any example if the above approach is correct too.<br>
>>>>><br>
>>>>> Thanks and Regards.<br>
>>>>> _______________________________________________<br>
>>>>> cfe-users mailing list<br>
>>>>> <a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
>>>>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>