[LLVMdev] Intrinsic::getDeclaration causing dump() segfault

Duncan Sands baldrick at free.fr
Mon Jul 2 11:03:55 PDT 2012


Hi Michael, when developing with LLVM you should always build LLVM with
assertions enabled, as then you get informative messages rather than
mysterious crashes.

Ciao, Duncan.

> In the following scrap of code (pared down from actually useful code),
> the func->dump() command segfaults iff the commented-out line is
> uncommented.  This is with llvm 3.0.  I'm only dipping my toes into the
> waters of llvm for the first time, and have no idea what I am doing
> incorrectly.  In actual code, I would be wanting to call the memcpy
> intrinsic eventually, of course.
>
> int main(void)
> {
>      Module *module = new Module("testmod", getGlobalContext());
>      FunctionType *ft = FunctionType::get(
>          Type::getInt1Ty(getGlobalContext()), false);
>      Function *func = Function::Create(ft, Function::ExternalLinkage,
>                                        "", module);
>      BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", func);
>      builder.SetInsertPoint(bb);
>      builder.CreateRet(ConstantInt::getTrue(getGlobalContext()));
>      // Value *memcpy = Intrinsic::getDeclaration(
>      //     module, Intrinsic::memcpy, Type::getInt64Ty(getGlobalContext()));
>
>      func->dump();
>
>      delete module;
>
>      return 0;
> }
>
>





More information about the llvm-dev mailing list