<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div><div>Hi Everyone,</div><div>  I am trying to construct the print statement : printf("value:%d\n", value); </div>
<div>This is my llvm code. It is seg faulting at builder.CreateGlobalStringPtr(str,"").</div><div>Thanks.</div><div><br></div><div>George</div><div><br></div><div>vector<const Type *> params;</div><div>params.push_back(Type::getInt8PtrTy(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>const char *str = "value: %d\n";</div><div>Value *intparam = ...</div>
<div><div>Value *strPtr = builder.CreateGlobalStringPtr(str,"");</div></div><div><div>builder.CreateCall2(PrintF, strPtr, intparam,"tmp6");</div></div></span>