Hi All,<div>  I am trying to insert printf ("%d", v), where v is an integer param, into the IR.</div><div>I am doing something wrong because I keep getting segfaults.</div><div>Below is my code. Thanks.</div><div>
<br></div><div><br></div><div><div>vector<const Type *> params;</div><div>params.push_back(Type::getInt8PtrTy(M.getContext()));</div><div>params.push_back(Type::getInt32Ty(M.getContext()));</div><div>FunctionType *fType = FunctionType::get(Type::getInt32Ty(M.getContext()), params, true);</div>
<div>Constant *temp = M.getOrInsertFunction("printf",fType);</div><div>if(!temp){</div><div>  errs() << "printf function not in symbol table\n";</div><div>  exit(1);</div><div>}</div><div>Function *f = cast<Function>(temp);</div>
<div>f->setCallingConv(CallingConv::C);</div></div><div><br></div><div>Value *intparam = ...</div><div><div>Value *strPtr = builder.CreateGlobalStringPtr(str,"");</div></div><div><div>builder.CreateCall2(PrintF, strPtr, intparam,"tmp6");</div>
</div><div><br></div><div><br></div>