[LLVMdev] Cloning a function with a changed return type

Chris Lattner sabre at nondot.org
Tue Mar 11 10:56:48 PDT 2008

On Mar 11, 2008, at 5:53 AM, Prabhat Kumar Saraswat wrote:

>   Thus, a better thing to do would be to remove the return value
> statements from the function, but then there are consistency issues
> with the function declaration, as the function is declared with a
> return type.
>   Thus, my questions are:
>   1. Is it possible to clone all basic blocks of the function, along
> with the function arguments, inside another function, but changing the
> type of the function (mainly(only) the return type).

Yes, there are two ways to do this.  You could keep the return value  
and change all returns to just return undef, this is easy but may not  
be sufficient for your needs.

The second way is to actually change the function.  Please look at the  
standard Dead Argument Elimination pass to see how this is done.


More information about the llvm-dev mailing list