[LLVMdev] create dummy function

Oleg Knut oleg77 at gmail.com
Thu Nov 5 02:30:49 PST 2009


Hello,
I have a simple question. How to create "dummy" function which will
have no functionality behind (return nothing and do nothing)?
Currently I'm trying to do this:

llvm::Constant* c = Module.getOrInsertFunction("dummy",
FunctionThatNeedsToBeReplaced.getFunctionType());
llvm::Function* dummy = llvm::cast<llvm::Function>(c);

This way I create new function that do nothing.Then next step is:

FunctionThatNeedsToBeReplaced.replaceAllUsesWith(dummy);

This code is doing what I want to do, but it ends up with exception:
ERROR: Program used external function 'dummy' which could not be resolved!

I think I'm doing something wrong or there is a different way to
create such functions.


Thank you in advance,
Oleg.



More information about the llvm-dev mailing list