[LLVMdev] Inserting Calls to var args Functions

Manish Gupta manishg at cs.ucsd.edu
Sun Aug 31 21:28:07 PDT 2014


Thanks!

---------
FunctionType *FuncTy = FunctionType::get(VoidType, args, true);
 RecordVarArgs =
cast<Function>(M.getOrInsertFunction("recordVarInputValues",
                                                        FuncTy));


On Sun, Aug 31, 2014 at 2:09 PM, John Criswell <criswell at illinois.edu>
wrote:

>  Dear Manish,
>
> For a varargs function, I think you'll need to use the version of
> Module::getOrInsertFunction() that takes a FunctionType.  That
> FunctionType, in turn, can be created so that is has a vararg type (see
> http://llvm.org/doxygen/classllvm_1_1FunctionType.html#ab781285a21baf484d3023a63da798fc7
> ).
>
> Regards,
>
> John Criswell
>
>
> On 8/31/14, 4:29 PM, Manish Gupta wrote:
>
> Hi All,
>
>  I am using code similar to giri instrumentation
> <https://github.com/liuml07/giri> framework to insert my instrumentation
> code. It works for normal functions for example to insert recordInt32
> function below.
>
>  void recordInt32(int32_t val){
>  printf("%d, ", val);
> }
>
>  I can get recodedInt32 function in my Module using  getOrInsert
> Function.
>
>  Function* RecordInt32 =
> cast<Function>(M.getOrInsertFunction("recordInt32",
>                                               VoidType,
>                                               Int32Type,
>                                               NULL));
>
>  and insert at desired instPoint using:
>
>  CallInst::Create(RecordInt32, args, "", instPoint);
>
>  What should be the similar instructions for recoedVarInsputValues below:
>
>  void recordVarInputValues(int num, ...){ CODE }
>
>  I am not able to figure out what will be the argument to
> getOrInsertFunction for "...".
>
>  Thanks!
> Manish
>
>
> _______________________________________________
> LLVM Developers mailing listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140831/7727df11/attachment.html>


More information about the llvm-dev mailing list