hello all, 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? Thanks in advance.. Abhinav
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
Hi Bill, Thanks a lot for your response.But my problem still remains.The thing is i am having a data type std::vector<Value*> as i am checking for the variables in Store Instructions and Malloc Instructions.For store the case is straightforward as discussed earlier.I want the same Value* variable for malloc inst as well. bcos i cannot have a different set for only instructions. can there be some way that i can get only the Value* and not the entire Instruction* ? Please help. Thanks. Hope my doubt is not that silly..> 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 > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu > lists.cs.uiuc.edu/mailman/listinfo/llvmdev >