<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [LLVMdev] whether these transformations are doable and how?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>>> 3.  can I modify a function to take extra formal parameters? can I<BR>
>> update all calls of the original function to take extra actual<BR>
>> paramters?  The function might be called across multiple modules.   It<BR>
>> seems this has to be done at both ModulePass and FunctionPass levels.<BR>
<BR>
> Since this is a global change, use a ModulePass.<BR>
<BR>
> This change is a bit more difficult.  First, to add parameters, I<BR>
> believe you can't change the original function; you have to create a<BR>
> new, empty function with the new parameters and then clone the body of<BR>
> the old function into the new function.  There's a utility function (I<BR>
> think it's in llvm/lib/Transform/Utils) that helps do this.<BR>
<BR>
>Updating callers is a bit more difficult.  Direct callers are easy; just<BR>
<BR>
PIC16 Target does both the things.<BR>
See the PIC16Cloner pass inside lib/Target/PIC16/PIC16Passes directory.<BR>
<BR>
- Sanjiv<BR>
<BR>
<BR>
_______________________________________________<BR>
LLVM Developers mailing list<BR>
LLVMdev@cs.uiuc.edu         <A HREF="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</A><BR>
<A HREF="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A><BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>