[LLVMdev] Setting called value for an indirect function call

John Criswell criswell at illinois.edu
Wed Oct 30 11:03:49 PDT 2013


On 10/30/13 12:22 PM, Arnamoy Bhattacharyya wrote:
> Hello;
>
> I am trying to clone some call instructions in the IR and then set the
> call destination of those call instructions to my own library
> functions that happens to have the same arguments and return types of
> the original callee.
>
> It works perfectly for direct calls using setCalledFunction().  But
> when the function call is indirect, is there a way to set the callee?
> Something like setCalledValue()?  How do I achieve this?
>
> Any help will be appreciated, thanks a lot!
>

Try the setCalledFunction() method of CallInst.  Despite the name, it 
looks like it takes a generic Value *, which means it should be able to 
set the called function operand to either a Function * or to a computed, 
indirect value (e.g., a Value *).

-- John T.




More information about the llvm-dev mailing list