[LLVMdev] Accessing Return Variable Names

Dmitry N. Mikushin maemarcus at gmail.com
Thu Jul 5 15:15:18 PDT 2012


Not in FAQ, but mentioned here:
http://llvm.org/docs/tutorial/LangImpl3.html#exprs

"One nice thing about LLVM is that the name is just a hint. For
instance, if the code above emits multiple "addtmp" variables, LLVM
will automatically provide each one with an increasing, unique numeric
suffix. Local value names for instructions are purely optional, but it
makes it much easier to read the IR dumps."

Probably could be taken here http://llvm.org/docs/FAQ.html but I don't
understand where this file is hosted to send a patch commit.

- D.

2012/7/5 Sean Silva <silvas at purdue.edu>:
>> Welcome, and this is a frequent newbie question: [...]
>
> If not already there, could you find an appropriate place to put this
> in the documentation?
>
> --Sean Silva
>
> On Thu, Jul 5, 2012 at 2:29 PM, Dmitry N. Mikushin <maemarcus at gmail.com> wrote:
>> Hi John,
>>
>> Welcome, and this is a frequent newbie question: in LLVM names are
>> more for human readability of the code, they are not really used as
>> references internally. Instead engine operates instructions, which
>> could be "used by" or "user of" other instructions (see use_iterator
>> of Value.h). Also the Function class has an iterator of BasicBlocks,
>> and each BasicBlock has an iterator of Instructions. For example, you
>> can iterate through all instructions in the scope of your interest and
>> find those, whose type is ReturnInst.
>>
>> Hope it helps,
>> - Dima.
>>
>> 2012/7/5 John Backes <back0145 at umn.edu>:
>>> Hello,
>>>
>>> I'm new to llvm development and I have a question which I think should
>>> be straight forward, but I am having trouble figuring it out.  I want to
>>> be able to access the return variable name for an instruction.  For some
>>> instructions I can get this value through the "getName" method.  For
>>> example, with the instruction:
>>>
>>>  > %arg11 = bitcast i32* %arg1 to i8*, !dbg !42, !id !43
>>>
>>> calling the "getName" method returns:
>>>
>>>  > arg11
>>>
>>> However, for the instruction:
>>>
>>>  > %4 = load i32* %arg1, align 4, !dbg !57, !id !59
>>>
>>> the "getName" method returns the empty string.  How would I find the
>>> value "4" for this load instruction?  Thanks in advance.
>>>
>>> - John
>>>
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list