[LLVMdev] How do I insert a printf call in the IR?

Shah, Mrunal J mrunal.shah at gatech.edu
Sat Nov 15 16:42:51 PST 2008

Hi Everyone,

I want to generate IR for the following C code
printf("Hello World!");

To insert a printf call in the IR, I use

Function* myPrint = M.getFunction("printf");

to get the function from my symbol table.

Once I have the function
to make a call to this function I use

CallInst::Create(myPrint, args.begin(), args.end(),"", B);

But I am not being able to pass a string into the argument vector.
should I define args as
std::vector<const Type*> args;
std::vector<const PointerType*> args;
std::vector<Value*> args;

and how do I convert a constant string to either of these types, so that I can push it on the args list.


More information about the llvm-dev mailing list