cloning function

Hello Everyone,

I am writing an llvm pass which clones a function.
For example, foo is cloned to my_foo.
It has all the instructions which are in foo and it works fine till the function is not called using a function pointer. I have used CloneFunction defined in Utils/CloneFunction.cpp. I am wondering how I can handle the case when function is called using a function pointer. Any insights or leads on how this can be achieved in llvm?


What happens when it’s called via a function pointer? (What compilation errors or assertions are generated?)

But in the most general case, an indirect function call doesn’t know what function it’s calling - and if it doesn’t know, what can you clone? Perhaps you may want to implement a wrapper function instead of a clone in that case? Depending on what your goals are