[LLVMdev] Return Type of Call Function with nested bitcast

Manish Gupta manishg at cs.ucsd.edu
Tue Jul 8 17:04:22 PDT 2014


Thanks!! John. This has been extremely helpful.
Manish


On Mon, Jul 7, 2014 at 5:59 PM, John Criswell <jtcriswel at gmail.com> wrote:

>  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 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/20140708/1f160a4c/attachment.html>


More information about the llvm-dev mailing list