[LLVMdev] Instrumenting Various Types Using Single Instrumentation Function

Manish Gupta manishg at cs.ucsd.edu
Tue Sep 2 16:08:48 PDT 2014


Thanks again John. I am working on it. Once I get it working. I will post
the relevant instructions for others to take a look, in future, and
complete the loop. Thanks again.


On Mon, Sep 1, 2014 at 5:13 PM, John Criswell <jtcriswel at gmail.com> wrote:

>  Dear Manish,
>
> Union types in LLVM are points to structures, so casting 8, 16, 32, and 64
> bit values to a union pointer is probably not what you want.
>
> I think the easiest thing to do is to:
>
> 1) Change the function in your run-time library to take the largest
> integer size supported by your target.
>
> 2) Change the instrumentation code to cast all values (including pointers)
> to this type.
>
> I'm not sure if CastInst::isCastable() is what you want to use to check to
> see that the casting can be done.  I would just go ahead and use the
> bit-cast since, for the call, you should always be casting from a type with
> lower bit-width to higher bit-width.  If you enable assertions when you
> build LLVM, then you should get an assertion if you try to create a Bitcast
> instruction that isn't going to work.
>
> Regards,
>
> John Criswell
>
>
>
> On 9/1/14, 4:50 PM, Manish Gupta wrote:
>
>  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
>
>
> _______________________________________________
> 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/20140902/c7c07cf4/attachment.html>


More information about the llvm-dev mailing list