Akshay Jain
2013-Apr-16 09:41 UTC
[LLVMdev] creating and inserting a function with variable arguments
I have tried it, but I always end up with some kind of error. Can you explain how can I get a function type for function which returns void (nothing) and it's arguments are (int, int, int, void *, void *, ...) ?? Thanks in advance. On Tue, Apr 16, 2013 at 7:22 AM, Óscar Fuentes <ofv at wanadoo.es> wrote:> Akshay Jain <jivan.molu at gmail.com> writes: > > > I am working on a pass in which I need to define and insert a function > with > > variable arguments. Can I do it with the help of getOrInsertFunction()? > > Sure. There is an overload of getOrInsertFunction that takes a > FunctionType, and there are FunctionType::get static methods where you > say if the function type takes a variable number of arguments. See the > doxygen documentation for FunctionType and Module::getOrInsertFunction. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- *Akshay Jain * -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130416/ea348371/attachment.html>
Óscar Fuentes
2013-Apr-16 10:11 UTC
[LLVMdev] creating and inserting a function with variable arguments
Akshay Jain <jivan.molu at gmail.com> writes:> I have tried it, but I always end up with some kind of error. Can you > explain how can I get a function type for function which returns void > (nothing) and it's arguments are (int, int, int, void *, void *, ...) ??Instead of getting something to cut&paste, you would be much more enriched if the problematic code and the resulting errors were shown for examination.
Akshay Jain
2013-Apr-16 13:34 UTC
[LLVMdev] creating and inserting a function with variable arguments
The code that I have written to get the function type is: const std::vector<Type *> ParamTys; ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(IntegerType::getInt32Ty(Context)); ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0)); ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0)); FunctionType *ftype = FunctionType::get(Type::getVoidTy(Context), ParamTys, true); And the errors are: /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp: In member function ‘virtual bool {anonymous}::Hello2::runOnFunction(llvm::Function&)’: /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:108:62: error: no matching function for call to ‘std::vector<llvm::Type*>::push_back(const llvm::IntegerType*) const’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:108:62: note: candidate is: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = llvm::Type*, _Alloc std::allocator<llvm::Type*>, std::vector<_Tp, _Alloc>::value_type llvm::Type*] <near match> /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for argument 1 from ‘const llvm::IntegerType*’ to ‘llvm::Type* const&’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:109:62: error: no matching function for call to ‘std::vector<llvm::Type*>::push_back(const llvm::IntegerType*) const’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:109:62: note: candidate is: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = llvm::Type*, _Alloc std::allocator<llvm::Type*>, std::vector<_Tp, _Alloc>::value_type llvm::Type*] <near match> /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for argument 1 from ‘const llvm::IntegerType*’ to ‘llvm::Type* const&’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:110:62: error: no matching function for call to ‘std::vector<llvm::Type*>::push_back(const llvm::IntegerType*) const’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:110:62: note: candidate is: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = llvm::Type*, _Alloc std::allocator<llvm::Type*>, std::vector<_Tp, _Alloc>::value_type llvm::Type*] <near match> /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for argument 1 from ‘const llvm::IntegerType*’ to ‘llvm::Type* const&’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:111:75: error: no matching function for call to ‘std::vector<llvm::Type*>::push_back(llvm::PointerType*) const’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:111:75: note: candidate is: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = llvm::Type*, _Alloc std::allocator<llvm::Type*>, std::vector<_Tp, _Alloc>::value_type llvm::Type*] <near match> /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for implicit ‘this’ parameter from ‘const std::vector<llvm::Type*>*’ to ‘std::vector<llvm::Type*>*’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:112:75: error: no matching function for call to ‘std::vector<llvm::Type*>::push_back(llvm::PointerType*) const’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:112:75: note: candidate is: /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = llvm::Type*, _Alloc std::allocator<llvm::Type*>, std::vector<_Tp, _Alloc>::value_type llvm::Type*] <near match> /usr/include/c++/4.6/bits/stl_vector.h:826:7: note: no known conversion for implicit ‘this’ parameter from ‘const std::vector<llvm::Type*>*’ to ‘std::vector<llvm::Type*>*’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:114:91: error: no matching function for call to ‘llvm::FunctionType::get(const llvm::Type*, const std::vector<llvm::Type*>&, bool)’ /home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp:114:91: note: candidates are: /home/akshay/llvm/llvm-2.9/include/llvm/DerivedTypes.h:157:24: note: static llvm::FunctionType* llvm::FunctionType::get(const llvm::Type*, const std::vector<const llvm::Type*>&, bool) /home/akshay/llvm/llvm-2.9/include/llvm/DerivedTypes.h:157:24: note: no known conversion for argument 2 from ‘const std::vector<llvm::Type*>’ to ‘const std::vector<const llvm::Type*>&’ It may be a silly mistake, but I am quite new to c and c++ coding especially in llvm. So I will be very grateful if you can help out. On Tue, Apr 16, 2013 at 3:41 PM, Óscar Fuentes <ofv at wanadoo.es> wrote:> Akshay Jain <jivan.molu at gmail.com> writes: > > > I have tried it, but I always end up with some kind of error. Can you > > explain how can I get a function type for function which returns void > > (nothing) and it's arguments are (int, int, int, void *, void *, ...) ?? > > Instead of getting something to cut&paste, you would be much more > enriched if the problematic code and the resulting errors were shown for > examination. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- *Akshay Jain * -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130416/fafbb0b8/attachment.html>
Maybe Matching Threads
- [LLVMdev] creating and inserting a function with variable arguments
- [LLVMdev] creating and inserting a function with variable arguments
- rimage installation problem-ubuntu 8.10
- [LLVMdev] creating and inserting a function with variable arguments
- [LLVMdev] creating and inserting a function with variable arguments