<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">On 7/7/14, 6:47 PM, Manish Gupta wrote:<br>
</div>
<blockquote
cite="mid:CAL6s+WkE6bK8L1VugmyoP3NOE-xAw3yhx1d0KvN4vgCdMWC8aw@mail.gmail.com"
type="cite">
<div dir="ltr">Hi All,
<div><br>
</div>
<div>I am facing an issue with CallInst with nested bitcast
instruction. I want to check if the return type of a call is
void or non-void the below line works well for CallInst
without bit cast.</div>
</div>
</blockquote>
<br>
First, there's a difference between the return type of the CallInst
and the return type of the function being called (because you can
cast function constants). If you want the value that will be used
by users of the CallInst, simply look at the type of the CallInst.<br>
<br>
If you want the return type of the Function constant, you need to
use getCalledValue()->stripPointerCasts() to get the Function
constant (assuming that there is one; it could also be an indirect
call with some non-const value as the function pointer). So, you'd
do:<br>
<br>
if (Function * F =
dyn_cast<Function>(I->getCalledValue()->stripPointerCasts()))
{<br>
... do whatever...<br>
}<br>
<br>
Regards,<br>
<br>
John Criswell<br>
<br>
<blockquote
cite="mid:CAL6s+WkE6bK8L1VugmyoP3NOE-xAw3yhx1d0KvN4vgCdMWC8aw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div><b>cast<CallInst>(I)->getCalledFunction()->getReturnType()->isVoidTy()</b></div>
<div><br>
</div>
<div>But for Call instructions like </div>
<div><b>call void bitcast (void
(%struct.jpeg_compress_struct.131*, i32)*
@jinit_c_master_control to void
(%struct.jpeg_compress_struct.109*,
i32)*)(%struct.jpeg_compress_struct.109* %0, i32 0)</b></div>
<div><b><br>
</b></div>
<div>getCalledFuncion returns null and the pass crashes.</div>
<div><br>
</div>
<div>Thanks!</div>
<div>Manish</div>
<div><b><br>
</b></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>