Hi, I want to insert a function with a void type parameter, for example: int foo(void); OI declared fcall2 = M.getOrInsertFunction("foo", IntegerType::get(M.getContext(), 32), Type::getVoidTy(M.getContext())); then the question is how to get the void type value to make the CallInst inserted sucessfully? (what should be ********) CallInst::Create(fcall2, ******, "", insertPos); -- --Shuying
o.j.sivart at gmail.com
2010-Nov-23 01:07 UTC
[LLVMdev] how to get a void type value in llvm
Hi Shuying, You will find in the documentation that amongst the overloaded CallInst::Create()'s there is one that takes no function arguments: static CallInst* llvm::CallInst::Create ( Value * F, const Twine & NameStr, BasicBlock * InsertAtEnd); Regards On 23/11/2010, at 11:20 AM, Shuying Liang wrote:> Hi, I want to insert a function with a void type parameter, > for example: int foo(void); > OI declared > fcall2 = M.getOrInsertFunction("foo", > IntegerType::get(M.getContext(), 32), > Type::getVoidTy(M.getContext())); > > then the question is how to get the void type value to make the > CallInst inserted sucessfully? (what should be ********) > CallInst::Create(fcall2, ******, "", insertPos); > > > -- > > --Shuying > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101123/69a74b53/attachment.html>
Hi, sivart Thanks for pointing it out. I used it, and it works. Thank you again. BTW, for any later reference, the function prototype declaration with no arguments is not what I wrote: fcall2 = M.getOrInsertFunction("foo", IntegerType::get(M.getContext(), 32), Type::getVoidTy(M.getContext())); INSTEAD, I changed to : fcall2 = M.getOrInsertFunction("foo", FunctionType::get( IntegerType::get(M.getContext(), 32), false)); combining with this, the insertion works finally. Thanks, --Shuying On Mon, Nov 22, 2010 at 6:07 PM, <o.j.sivart at gmail.com> wrote:> Hi Shuying, > You will find in the documentation that amongst the > overloaded CallInst::Create()'s there is one that takes no function > arguments: > static CallInst* > llvm::CallInst::Create ( Value * F, const Twine & NameStr, BasicBlock * InsertAtEnd); > > Regards > On 23/11/2010, at 11:20 AM, Shuying Liang wrote: > > Hi, I want to insert a function with a void type parameter, > for example: int foo(void); > OI declared > fcall2 = M.getOrInsertFunction("foo", > IntegerType::get(M.getContext(), 32), > Type::getVoidTy(M.getContext())); > > then the question is how to get the void type value to make the > CallInst inserted sucessfully? (what should be ********) > CallInst::Create(fcall2, ******, "", insertPos); > > > -- > > --Shuying > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- --Shuying
Reasonably Related Threads
- [LLVMdev] how to get a void type value in llvm
- [LLVMdev] how to get a void type value in llvm
- [LLVMdev] reference to non-static member function must be called
- [LLVMdev] reference to non-static member function must be called
- [LLVMdev] creating and inserting a function with variable arguments