<div dir="ltr"><div><div><div>Hi everyone,<br><br></div>I am trying to replace the call of a certain function with a call to another function. It would for example replace the following:<br><br>%call = tail call noalias i8* @func(i64 10)<br></div><div>by<br>%call = tail call noalias i8* @other_func(i64 10)<br></div><div><br></div><div>I managed to declare other_func correctly but I am having troubles to understand how I should proceed to do the replacement.<br></div><div><br>I tried to use ReplaceInstWithInst function as follows:<br><br>CallInst *call_to_other_func_inst = IRBuilder.CreateCall(ptr_to_other_func, args);<br>ReplaceInstWithInst(call_to_func_inst, newI);<br><br></div>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?<br><br>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?<br><br></div><div>Thanks for your help,<br></div><div>Pierre<br></div></div>