[LLVMdev] Question in LLVM IR

Eli Friedman eli.friedman at gmail.com
Sun Nov 30 19:48:16 PST 2008

On Sun, Nov 30, 2008 at 7:38 PM, bhavani krishnan <bhavi63 at yahoo.com> wrote:
> Hi all,
> I observed the nature of the LLVM IR and because of the SSA form, it does not preserve function local variable names (like it preserves function argument names). Is there any way to track these local variables?
> Basically what I am doing is interpreting the IR against an abstract machien where I need to store the value of each program variable at any instance. Here I would get values for registers but how do I map them back to original program variables?

Basically, the loads/stores are getting killed by optimization;
there's no real way to guarantee that the values are ever even
calculated.  You could use debug information in theory, but LLVM
doesn't properly support optimization with debug info at the moment.
Another way would be to use clang, and add some sort of
instrumentation to every store; this would keep the values, but
interfere with optimizations.  The other approach is to just disable
optimizations; then you can track the variables quite easily, but
you're not really instrumenting the same program.  Overall, there
really isn't a good solution to what you're trying to do.


More information about the llvm-dev mailing list