[LLVMdev] create dummy function

Renato Golin rengolin at systemcall.org
Thu Nov 5 03:20:38 PST 2009


2009/11/5 Oleg Knut <oleg77 at gmail.com>:
> 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);

Hi Oleg,

Every function needs a BasicBlock, even if the basic block just
contains a return.

The only reason to create a function without a basic block is when the
function is extern'd and imported via JIT, but I guess it's not what
you're attempting.

Try this presentation and let me know if it's helpful:

http://www.systemcall.org/rengolin/stuff/compiler/download/LLVM-pet-project.pdf

cheers,
--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm



More information about the llvm-dev mailing list