[LLVMdev] Question about local variables

Ryan Taylor ryta1203 at gmail.com
Sat Oct 22 12:58:34 PDT 2011


Those are the ones I am refering to. The description for instnamer says that
it names unnamed instructions (not operands), or am I confused on the
terminology here?

For example, if I print out I->getName I get "add" not "x" or "y", but when
I do Value *V = I->getOperands(loop) and then do V->getName, then it prints
out the name of the operand. Am I going about this backwards? It sounds like
it from the terminology you are using (calling an operand an instruction).

I don't mean to be contentious (as I really appreciate your time and help)
but apparently someone does use it, me. When going from source to source
it's needed to keep track of the variables. Or am I missing something here
too?



On Sat, Oct 22, 2011 at 12:51 PM, Nick Lewycky <nicholas at mxc.ca> wrote:

> 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
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111022/913737b4/attachment.html>


More information about the llvm-dev mailing list