[LLVMdev] Instrumenting Various Types Using Single Instrumentation Function
John Criswell
jtcriswel at gmail.com
Mon Sep 1 17:13:56 PDT 2014
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 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/20140901/23a75e18/attachment.html>
More information about the llvm-dev
mailing list