Thank you very much for you help, Renato!
I read through paper you referred and also this document -
http://llvm.org/docs/tutorial/JITTutorial1.html
Following these instructions to create successful function I run into
some problems:
1) llvm::getGlobalContext() does not exists anymore?
"llvm/LLVMContext.h" too?
2) creating instance of IRBuilder don't require template (from
tutorial paper - IRBuilder<> builder(block))
So, I believe this is just outdated information? I think it just need
some quick attention with getting materials up to date.
In the end I got following code, that satisfy my needs:
llvm::Constant* c = M.getOrInsertFunction(dummyFunctionName,
F.getFunctionType());
llvm::Function* dummy = llvm::cast<llvm::Function>(c);
dummy->setLinkage(llvm::Function::ExternalLinkage);
dummy->setCallingConv(llvm::CallingConv::C);
llvm::BasicBlock* block = llvm::BasicBlock::Create("entry", dummy);
// no context needed
llvm::IRBuilder builder(block); // no need in <>
builder.CreateRetVoid();
Cheers,
Oleg.
2009/11/5 Renato Golin <rengolin at
systemcall.org>:> 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
>