[LLVMdev] Accessing Return Variable Names

Dmitry N. Mikushin maemarcus at gmail.com
Thu Jul 5 14:29:55 PDT 2012


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



More information about the llvm-dev mailing list