<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Dear Manish,<br>
<br>
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.<br>
<br>
I think the easiest thing to do is to:<br>
<br>
1) Change the function in your run-time library to take the
largest integer size supported by your target.<br>
<br>
2) Change the instrumentation code to cast all values (including
pointers) to this type.<br>
<br>
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.<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<br>
On 9/1/14, 4:50 PM, Manish Gupta wrote:<br>
</div>
<blockquote
cite="mid:CAL6s+Wn0zEnUpa3ze2vMdO03PJi+8s-xo_TeOmWgoExc8xmHwg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Hi All,</div>
<div><br>
</div>
<div><br>
</div>
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 <a
moz-do-not-send="true" href="https://github.com/liuml07/giri">https://github.com/liuml07/giri</a>
<div>
<br>
</div>
<div>
<div>union NumericType</div>
<div>{</div>
<div> int iValue;</div>
<div> long lValue; </div>
<div> double dValue; </div>
<div> ...</div>
<div>};</div>
</div>
<div><br>
</div>
<div>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. </div>
<div><br>
</div>
<div>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...</div>
<div><br>
</div>
<div>
<div>if(!CastInst::isCastable(Lvals[j]->getType(),
UnionVar->getType())){</div>
<div> errs()<<"CAST TO NumericType NOT POSSIBLE\n";</div>
<div> exit(0);</div>
<div> } </div>
<div> CastInst *I = CastInst::CreateZExtOrBitCast(Lvals[j],
UnionVar->getType(), "", F);</div>
<div> </div>
</div>
<div><br>
</div>
<div>Is this even possible or some other method will be better? </div>
<div><br>
</div>
<div>Thanks!</div>
<div>Manish</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>