Call printf with new args

Hello,

My code: (CallInst *CI, IRBuilder<> &B)

SmallVector<Value *, 8> args;
Value *v = B.CreateGlobalString(“hi”, “str”);
args.push_back(v);

SmallVector<Type*, 8> params;
params.push_back(v->getType());

Module *M = B.GetInsertBlock()->getParent()->getParent();

FunctionType printfType = FunctionType::get(B.getInt32Ty(), params, true);
Constant
const_printf = M->getOrInsertFunction(“printf”, printfType);
Function *F = cast(const_printf);
F->dump();
CallInst * opInst = B.CreateCall(F, args, “call”);

It crashes with:
void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRefllvm::Value*, llvm::ArrayRef<llvm::OperandBundleDefTllvm::Value* >, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && “Calling a function with a bad signature!”’ failed.

Any advices how to fix it? Thanks

This should be "FunctionType::get(B.getInt32Ty(), B.getInt8PtrTy(), true)".

-Eli