[LLVMdev] Change the return type of a function
John Criswell
criswell at illinois.edu
Sat May 7 16:36:18 PDT 2011
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
> <http://www.cse.iitb.ac.in/%7Eramaswamy>
>
>
> _______________________________________________
> 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/20110507/2b968e37/attachment.html>
More information about the llvm-dev
mailing list