[LLVMdev] Question about local variables

Nick Lewycky nicholas at mxc.ca
Sat Oct 22 12:51:09 PDT 2011


Ryan Taylor wrote:
> Nick,
>
>     Unfortunately this doesn't answer my question I don't think. It
> seems that -instnamer, as you mention, names the instructions but still
> does not name the local variables.

What other local variables are you referring to? When AsmWriter prints 
"%y = add i32 %x, 1", the name of that add instruction is "y" and "x" is 
the name of another instruction or argument. If it has no name, the 
AsmWriter emits a number ("%0"), by counting from the top. The only 
other locals could be function arguments, and instnamer names those too.

>     So there really is no way to do this shy of creating (or basically
> copying) the API from AsmWriter (seems very dedundant to me)? This seems
> like a large failing?

Correct, you'd have to copy that logic.

It's not a large failing because nobody uses names of non-globals for 
anything. When we want to refer to a value, we use the Value*.

Nick

>
> On Fri, Oct 21, 2011 at 7:03 PM, Nick Lewycky <nicholas at mxc.ca
> <mailto:nicholas at mxc.ca>> wrote:
>
>     Ryan Taylor wrote:
>
>         It looks like the AsmWriter is generating the local variables
>         (SlotNum)s
>         on the fly in that file (AsmWriter.cpp), so is there any way at
>         all to
>         get this information from the operation itself, via Instruction,
>         Value
>         or Type?
>
>
>     Nope! As you noticed, they're created on the fly...
>
>     ...when the Value or Type is anonymous. If you want them to be
>     persistent, values can have names via. the setName() call. "opt
>     -instnamer" will name all your instructions, for example.
>
>     Nick
>
>




More information about the llvm-dev mailing list