How to duplicate a function?

Hi all,

Sorry for the inconvenient about the previous post. The files were not attached. So I put them here again.

I am a newbie in LLVM and I am trying to replace the function like:

old function || new function

Hi Shawn,

Probably I can answer specifically the question "how to replace old
function call with new one, adding extra char* argument".

Method for gathering information: grep with context for one keyword in
LLVM source and then look for another in results:

find . -name *.cpp -exec grep "CallInst" {} -C 100 \; | less


1) tools/bugpoint/Miscompilation.cpp gives an example of creating
string array and adding it into call args list starting at line 826:

        Constant *InitArray = ConstantArray::get(F->getContext(), F->getName());
        GlobalVariable *funcName =

2) Using (1) I implemented my own version here, with more comments:

I hope it's helpful,
- D.

Hi Shawn, did you build LLVM with assertions enabled? You should, since you
then get helpful error messages rather than obscure crashes. Also, take a look
at ArgumentPromotion.cpp as an example of the kind of thing you are trying to

Ciao, Duncan.