[LLVMdev] Accessing instruction/operand names

Luke Dalessandro luked at cs.rochester.edu
Wed Apr 15 06:52:28 PDT 2009


James Stanier wrote:
> Hello everyone,
> 
> I'm currently constructing a graph from LLVM bitcode, and I have a question
> about accessing the names of the variables shown in the .ll assembly file,
> assuming it's possible...
> 
> For example, with
> 
> %2 = load i32* %x_addr, align 4		; <i32> [#uses=1]
> 
> I can retrieve the opcodeName() from the Instruction object, which is
> "load". I can also access the operand and use getName() to retrieve
> "x_addr". However, this instruction is storing into %2 - how do I access the
> name of that?
> 
> Also, when an operand is a numbered temporary such as
> 
> %3 = add i32 %2, %1		; <i32> [#uses=1]
> 
> I'm also unable to access the name of it. Are these numberings no longer
> present in the bitcode? If not, is there any way to find out the name of
> which local variable it is referencing?

This question seems a little bit confusing as written, given that LLVM 
IR is in SSA form. The actual names aren't really relevant to anything.

Maybe you could be more specific about the task you are trying to 
accomplish to get a good answer?

Luke

> 
> Thanks in advance - I've been stuck on this for a while.
> 
> Best,
> 
> James




More information about the llvm-dev mailing list