[LLVMdev] whether these transformations are doable and how?

Sanjiv.Gupta at microchip.com Sanjiv.Gupta at microchip.com
Fri Apr 9 07:46:49 PDT 2010


>> 3.  can I modify a function to take extra formal parameters? can I 
>> update all calls of the original function to take extra actual 
>> paramters?  The function might be called across multiple modules.   It 
>> seems this has to be done at both ModulePass and FunctionPass levels. 

> Since this is a global change, use a ModulePass.

> This change is a bit more difficult.  First, to add parameters, I 
> believe you can't change the original function; you have to create a 
> new, empty function with the new parameters and then clone the body of 
> the old function into the new function.  There's a utility function (I 
> think it's in llvm/lib/Transform/Utils) that helps do this.

>Updating callers is a bit more difficult.  Direct callers are easy; just 

PIC16 Target does both the things.
See the PIC16Cloner pass inside lib/Target/PIC16/PIC16Passes directory.

- Sanjiv


_______________________________________________
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/20100409/b6280ef2/attachment.html>


More information about the llvm-dev mailing list