[llvm-dev] function call replacement
Pierre Gagelin via llvm-dev
llvm-dev at lists.llvm.org
Mon Jun 20 04:17:01 PDT 2016
I am trying to replace the call of a certain function with a call to
another function. It would for example replace the following:
%call = tail call noalias i8* @func(i64 10)
%call = tail call noalias i8* @other_func(i64 10)
I managed to declare other_func correctly but I am having troubles to
understand how I should proceed to do the replacement.
I tried to use ReplaceInstWithInst function as follows:
CallInst *call_to_other_func_inst = IRBuilder.CreateCall(ptr_to_other_func,
LLVM builds correctly but the instrumentation crashes at optimization time.
I know this isn't the correct way to do it because IRBuilder generates IR
and I just want to have an instance of a CallInst. But I don't see how it
is supposed to be done?
There are methods to create CallInst in the Instruction.h file but those
needs to give an inserting point. Shoud I insert the call to other_func
before the one to func and just remove the call instruction to func?
Thanks for your help,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev