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

Michael Welsh Duggan md5i at md5i.com
Mon Jul 2 09:29:04 PDT 2012


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;
}


-- 
Michael Welsh Duggan
(md5i at md5i.com)




More information about the llvm-dev mailing list