[LLVMdev] How to replace a function using llvm?
yury.mikhaylov at gmail.com
Mon Sep 19 16:39:39 PDT 2011
I've just implemented something similar. It might be horribly wrong to do it
this way, but at least it works for me :-)
Here's what I do:
* Rename your function "haha" -> "haha_" to avoid name collisions in the
* Get its function type and modify to suite your needs: add new parameters,
change types, whatever;
* Create new function named "haha" with that signature;
* Relink all basic blocks from original function to the new one. Now "haha_"
is empty, but you can't delete it yet;
* Iterate over all modules/functions that reference your original function
and replace call instructions to match new signature;
* Delete "haha_" function.
I'm no LLVM expert by any means, so take this with a grain of salt..
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev