[LLVMdev] Changing the operands in the CallInst

Dmitry N. Mikushin maemarcus at gmail.com
Tue Dec 13 09:31:24 PST 2011


Hi Yakov,

For cases 2) and 3) - CallInst is bound to the underlying function
type, to my knowledge. So you cannot modify the function type, but
instead you can create another CallInst with different function type
and replace original one with it. If you do not change the return
type, replaceAllUsesWith method would work. In attached code example
CallInst replacement logic is in lines 223-285.

HTH,
- Dima.

2011/12/13 Yakov Malinkovich <yakovm3 at gmail.com>:
>
>
>
> I implement the following function,which gets CallInst * and should perform
> the following:
>
> Change the value of the argument if  condition1 takes place
> Change the type of the argument if condition2 takes place
> Add addition argument/s if condition3 takes place
>
>
> void argChange(CallInst * I)
>  {
>
> for (unsigned index = 0; index < I->getNumOperands(); ++index) {
> do_something_with (I->getOperand(index),condition);
>
>             }
> }
> I think that the 1. can be implemented using I->setOperand(index,newValue)
> Can anyone advice me how 2. & 3. could be implemented.
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compile.cpp
Type: text/x-c++src
Size: 9431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111213/56584649/attachment.cpp>


More information about the llvm-dev mailing list