[LLVMdev] LLVM Tutorial 1: Something got wrong?

王建东 computerhenu at gmail.com
Tue Apr 27 23:51:35 PDT 2010


it seems the code snippit below cann't be compiled throuth.

the compiler complains:
error: no matching function for call to ‘llvm::IntegerType::get(int)’
/usr/local/include/llvm/DerivedTypes.h:108:

note: candidates are: static const llvm::IntegerType*
llvm::IntegerType::get(llvm::LLVMContext&, unsigned int)


Module* makeLLVMModule() {
  // Module Construction
  Module* mod = new Module("test", getGlobalContext());


Constant* c = mod->getOrInsertFunction("mul_add",
  /*ret type*/                           IntegerType::get(32),
  /*args*/                               IntegerType::get(32),
                                         IntegerType::get(32),

                                         IntegerType::get(32),
  /*varargs terminated with null*/       NULL);

  Function* mul_add = cast<Function>(c);
  mul_add->setCallingConv(CallingConv::C);

-------------------------------------------------------------------

 when I change it into the following state, it works out smoothly.

Module* makeLLVMModule() {
  // Module Construction
  Module* mod = new Module("test", getGlobalContext());


Constant* c = mod->getOrInsertFunction("mul_add",
  /*ret type*/
IntegerType::get(getGlobalContext(),32),
  /*args*/
IntegerType::get(getGlobalContext(),32),


IntegerType::get(getGlobalContext(),32),

IntegerType::get(getGlobalContext(),32),

  /*varargs terminated with null*/       NULL);

  Function* mul_add = cast<Function>(c);
  mul_add->setCallingConv(CallingConv::C);

should the tutorial be modified?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100428/92ee2737/attachment.html>


More information about the llvm-dev mailing list