How to extract Left Hand side of Instruction

Hi,

Suppose I have llvm Instruction as :

  %9 = load i32* %b, align 4

and I want to extract the name of temporary value used here ie 9.
Can any body tell that how can I do that?

thanks and regards,
Ambika

Hi,

Suppose I have llvm Instruction as :

%9 = load i32* %b, align 4

and I want to extract the name of temporary value used here ie 9.
Can any body tell that how can I do that?

Values can be unnamed, they are numbered for convenience. If they do
have a name, you can call getName() or getNameStr() to find out the
name.

Andrew

ambika wrote:

Hi,

Suppose I have llvm Instruction as :

  %9 = load i32* %b, align 4

and I want to extract the name of temporary value used here ie 9.
Can any body tell that how can I do that?
  
I believe it's the getNameStr() method.

Note that not all instructions have names (i.e., getNameStr() might give you an empty string). I think the LLVM disassembler prints a number when the instruction has no name.

There's a pass which, I think, gives names to all values, but I don't recall the pass's name.

-- John T.

There is, though it's purely for cosmetic purposes, so it shouldn't be
a dependency. In the C++ API, values are identified by Value*,
rather than by name. The Value* for a load is the LoadInst* itself.
Because this is SSA, there are no other definitions of that value.

Dan