How can I find the LHS of the function call when traversing the function call

Hi All,

I am a new member in the group, have been doing some experiments with LLVM IR.

I am facing issue with de-compiling the following instruction once it is read,

%var2 = call i8 @myfuncCall (i2 %var1)

In after I parse the file (lets say using parseIRFiles ).
I can see the instructions,( the function call instruction ), How can I get the %var2 from the instruction/callInstruction ?

going thru the llvm installations cpp and .h files, it is not clear how do I get the desired variable.

Thanks in Advance.

regards
Tarique

The member function getName would return "var2" for it, but %var2 in here is a name of the value that is the function call instruction. In general this doesn't have to be the name of the variable from the source code.

Hi Tarique,

I am a new member in the group, have been doing some experiments with LLVM IR.

I am facing issue with de-compiling the following instruction once it is read,

  %var2 = call i8 @myfuncCall (i2 %var1)

In after I parse the file (lets say using parseIRFiles ).
I can see the instructions,( the function call instruction ), How can I get the
%var2 from the instruction/callInstruction ?

%var2 *is* the call instruction. Since LLVM IR is in SSA form, values like
%var2 are defined once and can't be redefined. Thus there is no point in
trying to make a distinction between %var2 and the instruction defining it,
which is why LLVM doesn't even try to make a distinction: there is no variable
%var2, there is only the instruction "call i8 @myfuncCall (i2 %var1)", and
%var2 is just a name attached to it (use ->getName() on the instruction to see
this).

Ciao, Duncan.