[LLVMdev] Inserting Calls to var args Functions

John Criswell criswell at illinois.edu
Sun Aug 31 14:09:17 PDT 2014


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 list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140831/fa717da6/attachment.html>


More information about the llvm-dev mailing list