[LLVMdev] Segment section

Jasmin Jahic jasmin.jahic at gmail.com
Thu Feb 20 10:19:34 PST 2014


Hello,

thank you for the reply. Let me give you concrete example, so you can
better understand to what I'm referring:
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?


On Thu, Feb 20, 2014 at 10:37 AM, Tim Northover <t.p.northover at gmail.com>wrote:

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


More information about the llvm-dev mailing list