[LLVMdev] LHS of an expression
Bill Wendling
isanbard at gmail.com
Mon Jul 23 13:06:36 PDT 2007
Hi Abhinav,
> If i have an IR instruction of the form
> %tmp10 = call sbyte* %malloc( uint 4 ) ; <sbyte*> [#uses=1]
> %tmp10 = cast sbyte* %tmp10 to int* ; <int*> [#uses=1]
> store int* %tmp10, int** %t
>
> which is nothin but a malloc call how can i get %tmp into maybe a variable
> set.
>
> If i have a store instruction then it is pretty much simpler as the
> getOperand(1) can give me the LHS of the expression but in the above case
> how can we get it.
>
> I tried searching for some stuff and got a method called getLHS() method
> using BinaryOperator and takes Binops as parameter but i dont think that
> is of much help if i am having a malloc instruction.
>
> Can anybody please guide me on this thing please?
The LHS of the instruction is a pointer to the instruction itself
(except in cases like the store instr, which you've figured out
already). You can think of the variables that are printed out in the
.ll file as syntactic sugar to help with debugging. So, if you want
variables in a set, you can do something like:
MallocInst *M = new MallocInst(...);
std::set<Instruction*> LHSs;
LHSs.insert(M);
-bw
More information about the llvm-dev
mailing list