[LLVMdev] Return Type of Call Function with nested bitcast

John Criswell jtcriswel at gmail.com
Mon Jul 7 17:59:33 PDT 2014


On 7/7/14, 6:47 PM, Manish Gupta wrote:
> Hi All,
>
> 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.

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.

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:

if (Function * F = 
dyn_cast<Function>(I->getCalledValue()->stripPointerCasts())) {
     ... do whatever...
}

Regards,

John Criswell

>
> *cast<CallInst>(I)->getCalledFunction()->getReturnType()->isVoidTy()*
>
> But for Call instructions like
> *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)*
> *
> *
> getCalledFuncion returns null and the pass crashes.
>
> 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/20140707/a8851439/attachment.html>


More information about the llvm-dev mailing list