marc chellarmani
2013-Dec-03 02:42 UTC
[LLVMdev] Help needed with creating new and replacing an old instruction
Hi,I have the following instruction in my IR-%call2 = call i8* @strcpy(i8* %1, i8* %2) #2I intend to change call to strcpy with strncpy. I have included the following code in runOnFunction, so that when it is strcpy's turn to be invoked, strncpy is invoked instead.Assuming I* is the strcpy instruction,CallInst* x=new CallInst::CreateCall3(strncpy,1,2,ConstantInt(16),"my_strncpy");ReplaceInstWithInst(I*,x);I'm running into a whole bunch of errors in CreateCall3(). How can I go about writing this correctly?Any help would be appreciated.Thanks.Marc----email.biz access any email create any email -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131203/94e567c3/attachment.html>
Bill Wendling
2013-Dec-09 08:47 UTC
[LLVMdev] Help needed with creating new and replacing an old instruction
On Dec 2, 2013, at 6:42 PM, marc chellarmani <marcchellarmani at email.biz> wrote:> Hi, > > I have the following instruction in my IR- > %call2 = call i8* @strcpy(i8* %1, i8* %2) #2 > > I intend to change call to strcpy with strncpy. I have included the following code in runOnFunction, so that when it is strcpy's turn to be invoked, strncpy is invoked instead. > > Assuming I* is the strcpy instruction, > > CallInst* x=new CallInst::CreateCall3(strncpy,1,2,ConstantInt(16),"my_strncpy"); > ReplaceInstWithInst(I*,x); > > I'm running into a whole bunch of errors in CreateCall3(). How can I go about writing this correctly? >You’re using ‘new’ incorrectly. The ‘CreateCall3’ does all of the allocation and creation of the call instruction. -bw -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131209/01bb2d4f/attachment.html>