[LLVMdev] Change the return type of a function

Gokul Ramaswamy ramaswamy at cse.iitb.ac.in
Sun May 8 03:36:20 PDT 2011


Thanks John for the reply. Ya, I took a similar approach. I cloned the
entire
function using CloneFunctionInto() in Cloning.h.

Now, I am facing a new Problem. I am not able to understand the concept of
ValueToValueMap. I am trying to figure it out by testing it. But I am
getting
errors like "Referring to an argument in another function!". I am not able
to get
good examples nor good documentation on ValueToValueMap. Can you point
me in the right direction ?


On Sun, May 8, 2011 at 5:06 AM, John Criswell <criswell at illinois.edu> wrote:

>  On 5/7/11 2:01 PM, Gokul Ramaswamy wrote:
>
> Hello All,
>
>       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.
> Assume that, I can handle the returning values properly inside the
> function. Please guide me how to do this ?
>
>
> You need to do the following steps:
>
> 1) Create a new function with the desired function type.
> 2) Clone the body of the old function into the new function
> 3) Find all calls calling the old function and replace them with calls to
> the new function.
>
> This is necessary because a function cannot have its type changed once it
> has been created.
>
> 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
>
> svn co http://llvm.org/svn/llvm-project/poolalloc/trunk poolalloc
>
> ... to get a copy from SVN.
>
> -- John T.
>
>
>
> --
> Regards,
> Gokul Ramaswamy,
> Graduate Student,
> Department of CSE, IIT Bombay
> http://www.cse.iitb.ac.in/~ramaswamy
>
>
> _______________________________________________
> LLVM Developers mailing listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>


-- 
Regards,
Gokul Ramaswamy,
Graduate Student,
Department of CSE, IIT Bombay
http://www.cse.iitb.ac.in/~ramaswamy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110508/6555b8b1/attachment.html>


More information about the llvm-dev mailing list