<div dir="ltr">"IR" often refers to the general concept/semantics, not only the textual format in .ll files (there are 3 main forms - bitcode, textual IR, and the in-memory representation (llvm::Module, etc - constructed using IRBuilder)).<br><br>A great place to start is to look at what Clang does to produce debug info - it uses IRBuilder, for instance. So you could look at how Clang uses the IRBuilder when compiling a small source file containing a local variable. You'll find it calls into DIBuilder (the debug info equivalent of IRBuilder) for constructing types and the location descriptions (see "insertDeclare"/insertDbgValueIntrinsic", etc.).</div><br><div class="gmail_quote"><div dir="ltr">On Sun, Apr 1, 2018 at 2:17 PM Vivien Millet via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Paul,<div>How can i make this call to intrinsic from the c++ code ? <br>I'm not working with the IR language, but directly in C++ with IRBuilder::CreateAlloca.<br>My goal is that one : <br>- Generate machine code with an instance of the class 'IRBuilder'<br>- Emit 'ObjFile' class instance with MCJIT <br>- Create a DwarfContext instance directly from the emitted ObjFile object (DwarfContextInMemory) (on JitEventListener::NotifyObjectEmitted)<br>- Use this DwarfContext to step into my home made runtime debugger.<br><br>Now I can perform step over/into/out in my debugger using the DwarfContext instance without problem, but I'm still stuck on how <br>to watch my local variables in my debugger (i can't figure out how to locate them in registers/stack from that DwarfContext)<br><br>Thanks for your help</div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-01 20:17 GMT+02:00  <span dir="ltr"><<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-6809687639314716382m_-3156570726146975106WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Binding the alloca to the debug-info metadata is not automatic.  You need to emit an intrinsic function call to llvm.dbg.declare to bind the two together.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">If you are simply trying to emit DWARF for your program, the rest of the processing should already be in place for that.  If you are trying to do something
 else, you would need to describe that so we understand what you need.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-6809687639314716382_m_-3156570726146975106__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></a></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 #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Vivien Millet via llvm-dev<br>
<b>Sent:</b> Saturday, March 31, 2018 7:33 AM<br>
<b>To:</b> llvm-dev<br>
<b>Subject:</b> [llvm-dev] [Dwarf] Register a local variable in DIBuilder and locate it later with a DwarfContext<u></u><u></u></span></p>
</div>
</div><div><div class="m_-6809687639314716382h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi,<br>
<br>
First, considering I'm using an IRBuilder and a DIBuilder to build my program, how can I automatically bind the CreateAlloca with my named local variable inside the DIBuilder ? Is it automatic with the Twine name of CreateAlloca ? And/Or should I use DIBuilder::createAutoVariable
 and how ?<u></u><u></u></p>
<div>
<p class="MsoNormal"><br>
Then, I'm wondering how to locate back my local variable in memory (register or stack) once i have a DwarfContext ready.<br>
<br>
I'm a bit lost with all this pipeline, sorry If my question seem trivial.<br>
<br>
Thanks !<br>
<br>
Vivien <u></u><u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>