<div dir="ltr">Hello,<div><br></div><div>thank you for the reply. Let me give you concrete example, so you can better understand to what I'm referring:</div><div>During the load process of variable, at some random point during execution (loadInst), how can I know (based on instruction or its value) is the variable allocated on the stack, in the heap or elsewhere?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 20, 2014 at 10:37 AM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> I've been playing lately a lot with LLVM Interpreter. During the execution<br>

> of IR I would like to know where my variables are allocated (e.g. stack,<br>
> heap, global). Is there a function inside of the execution engine which<br>
> provides such information?<br>
<br>
</div></div>Are you interested in the classification of an underlying address<br>
(likely to be invariant over an object's lifetime), or the value of<br>
the variable at some random point during execution (where the answer<br>
may be "it's in register r10 at the moment")?<br>
<br>
LLVM doesn't provide a function for the first one, you might start by<br>
looking is at a process's memory map (/proc/$PID/map on Linux,<br>
presumably with some libdl interface) and decide which part your<br>
address is in. Debuggers have to do this kind of thing, so you might<br>
find helpful source snippets there.<br>
<br>
For the second, we've recently got an @llvm.experimental.stackmap<br>
intrinsic (<a href="http://llvm.org/docs/StackMaps.html" target="_blank">http://llvm.org/docs/StackMaps.html</a>), which can provide the<br>
information in a separate area for use by JITs and so on. Its support<br>
may be limited at the moment though (x86 Darwin I'm fairly sure of,<br>
possibly Linux too by now).<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>