[LLVMdev] Instrumenting Various Types Using Single Instrumentation Function

Manish Gupta manishg at cs.ucsd.edu
Mon Sep 1 13:50:53 PDT 2014


Hi All,


My instrumentation code needs to insert calls to transmit Value list. Each
element in this list could be of different type. The list is sent to
instrumenting function say void recordVarInputValues(int num, ...) . So, I
have created a Union type in Tracing.cpp, which I link with my benchmark
module at compile time. These steps are similar to giri instrumentation
https://github.com/liuml07/giri

union NumericType
{
    int         iValue;
    long        lValue;
    double      dValue;
     ...
};

Now, I would like to convert all the llvm Values, required by
recordVarInputValues function, to be of NumericType. So that a variable
length list of NumerricType values can be passed to my instrumentation
function. This way I will not have to create different instrumentation
functions for different data types.

Can I cast say i32 value to NumericType value in my instrumentation code,
without inserting additional instructions in my benchmark code. I tried
inserting bitcast instructions and it doesn't work for me...

if(!CastInst::isCastable(Lvals[j]->getType(), UnionVar->getType())){
      errs()<<"CAST TO NumericType NOT POSSIBLE\n";
      exit(0);
    }
    CastInst *I = CastInst::CreateZExtOrBitCast(Lvals[j],
UnionVar->getType(), "", F);


Is this even possible or some other method will be better?

Thanks!
Manish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140901/7454021b/attachment.html>


More information about the llvm-dev mailing list