Inserting Calls to var args Functions

Hi All,

I am using code similar to giri instrumentation 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(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

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

Thanks!