[llvm-dev] Getting variable names from LLVM Pass

Ridwan Shariffdeen via llvm-dev llvm-dev at lists.llvm.org
Thu May 24 07:48:12 PDT 2018


Hi Michael,

Thanks for the help, it seems like you said its not going to be easy. But I
will have a try at this, thank you for the link to LibTooling.

Best

On Mon, May 21, 2018 at 6:26 PM Dean Michael Berris <dean.berris at gmail.com>
wrote:

>
>
> > On 21 May 2018, at 18:38, Ridwan Shariffdeen via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >
> > Hi,
> >
> > I want to retrieve the variable names used in a statement, I tried the
> following snippet,
> > but it only gives me the variable named in llvm bitcode. I need the
> variable name in source code.
> >
> > for (auto op = I.op_begin(); op != I.op_end(); op++) {
> >                         Value* v = op->get();
> >                         StringRef name = v->getName();
> > }
> >
> > Is there specific documentation I can refer to implement this?
> >
>
> If the source language is something clang knows about, you may have to
> implement that on top of libTooling, part of clang. Unfortunately it’s not
> quite straight-forward to get to the source from the LLVM — you’re going to
> have to rely on a reverse-mapping from the LLVM IR to the higher-level
> source location, which *might* be doable if there’s debug information
> associated with the LLVM IR.
>
> https://clang.llvm.org/docs/LibTooling.html
>
> Cheers
>
> -- Dean
>
> --
*Ridwan Shariffdeen*
Graduate Student | National University of Singapore
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180524/d122002f/attachment.html>


More information about the llvm-dev mailing list