[LLVMdev] How to create a CallInst that calls a standard c function like "printf"

Rich Dougherty rich at rd.gen.nz
Thu Jan 21 10:40:11 PST 2010


On Tue, Jan 19, 2010 at 2:08 AM, Mary_nju <miaoyisz at gmail.com> wrote:
> I am working on a program based on LLVM. I want to modify the .bc file
> throught C++ APIs provided by LLVM, but I don't know how to create a
> CallInst that calls a standard c function like "printf", can anyone help me
> with this problem?

Hi

A good way to work this kind of thing out is to use the online demo
application and look at the C++ code that it prints out when you
compile it.

e.g.

* Go to http://llvm.org/demo/
* Click "Show LLVM C++ API code"
* Click "Compile Source Code"

Search the code for "printf" and you should be able to easily see how
it is used.

Cheers
Rich

--
Rich Dougherty
http://www.richdougherty.com/



More information about the llvm-dev mailing list