Thanks John for the reply. Ya, I took a similar approach. I cloned the entire <br>function using CloneFunctionInto() in Cloning.h. <br><br>Now, I am facing a new Problem. I am not able to understand the concept of <br>ValueToValueMap. I am trying to figure it out by testing it. But I am getting <br>
errors like "Referring to an argument in another function!". I am not able to get<br>good examples nor good documentation on ValueToValueMap. Can you point <br>me in the right direction ?<br><br><br><div class="gmail_quote">
On Sun, May 8, 2011 at 5:06 AM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


  
    
  
  <div bgcolor="#ffffff" text="#000000"><div class="im">
    On 5/7/11 2:01 PM, Gokul Ramaswamy wrote:
    <blockquote type="cite">
      
      Hello All,<br>
      <br>
            I want to change the return type of a function in a Pass(in
      a module Pass). I dont want to change any of the arguments of that
      function.<br>
      Assume that, I can handle the returning values properly inside the
      function. Please guide me how to do this ?<br clear="all">
    </blockquote>
    <br></div>
    You need to do the following steps:<br>
    <br>
    1) Create a new function with the desired function type.<br>
    2) Clone the body of the old function into the new function<br>
    3) Find all calls calling the old function and replace them with
    calls to the new function.<br>
    <br>
    This is necessary because a function cannot have its type changed
    once it has been created.<br>
    <br>
    Automatic Pool Allocation adds parameters to functions (which is
    similar to what you need to do).  See MakeFunctionClone() in
    poolalloc/lib/PoolAllocate/PoolAllocate.cpp in the poolalloc
    project.  Use<br>
    <br>
    svn co <a href="http://llvm.org/svn/llvm-project/poolalloc/trunk" target="_blank">http://llvm.org/svn/llvm-project/poolalloc/trunk</a> poolalloc<br>
    <br>
    ... to get a copy from SVN.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote type="cite"><div class="im">
      <br>
      <br>
      -- <br>
      Regards,<br>
      Gokul Ramaswamy,<br>
      Graduate Student,<br>
      Department of CSE, IIT Bombay<br>
      <a href="http://www.cse.iitb.ac.in/%7Eramaswamy" target="_blank">http://www.cse.iitb.ac.in/~ramaswamy</a><br>
      </div><pre><fieldset></fieldset>
_______________________________________________
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><br clear="all"><br>-- <br>Regards,<br>Gokul Ramaswamy,<br>Graduate Student,<br>Department of CSE, IIT Bombay<br><a href="http://www.cse.iitb.ac.in/%7Eramaswamy" target="_blank">http://www.cse.iitb.ac.in/~ramaswamy</a><br>