[LLVMdev] How to duplicate a CallInst
Bill Wendling
wendling at apple.com
Fri Jan 6 12:45:54 PST 2012
On Jan 6, 2012, at 9:50 AM, Rafael Baldiati Parizi wrote:
> Hi,
> I have the following piece of code:
> %34 = fptosi float %33 to i32
> %35 = call i32 @function(i32 %34) nounwind
>
> I would like of know how can I duplicate the statement %35 ? , as follows:
> %34 = fptosi float %33 to i32
> %35 = call i32 @function(i32 %34) nounwind
> %36 = call i32 @function(i32 %34) nounwind
>
> i.e, two instructions exactly equal.
>
> Using clone, results in badref.
Did you insert the new call instruction it into the basic block?
> Moreover, how can I get the parameters of function?
>
> This is my experimental code that not is running wich I need:
> for (BasicBlock::iterator Is = i->begin(), e = i->end(); Is != e; ++Is){
> if(isa<CallInst>(*Is)){
> CallInst *call = dyn_cast<CallInst>(&*Is);
> Function* ft = call->getCalledFunction();
> arguments = ????
> CallInst *call2 = CallInst::Create(ft, arguments.begin(), arguments.end(), "", ++Is);
> }
> }
>
>
Look at the call->getNumArgOperands() and call->getArgOperand() methods.
-bw
More information about the llvm-dev
mailing list