<div dir="ltr">Thanks!! John. This has been extremely helpful. <div>Manish</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 7, 2014 at 5:59 PM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="">
    <div>On 7/7/14, 6:47 PM, Manish Gupta wrote:<br>
    </div>
    <blockquote 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></div>
    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 type="cite"><div class="">
      <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></fieldset>
      <br>
      </div><pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></div>