[LLVMdev] Add call printf instructions problems

Jin Huang 54jin.huang at gmail.com
Wed Dec 18 03:51:42 PST 2013


Thank you ,Cheers.
I also found a good example of inserting call "printf" instruction in
https://chromium.googlesource.com/chromiumos/third_party/llvm/+/release_16/lib/Transforms/Instrumentation/TraceValues.cpp

The code in this link also use GetOrInsertFunction().


2013/12/17 Tim Northover <t.p.northover at gmail.com>

> > But I got another problems. I successfully compile the pass and I can
> insert
> > the call printf (C Lib function) instructions in the LLVM IR(eg:
> call.bc).
> > If the call.bc didn't contain call printf instruction ,I can call printf
> > successfully ,but if not ,there exists a problem. the llvm will rename my
> > inserted call function , and the transformed code can not run correctly!
>
> That looks like the issue Hongxu mentioned: you're always creating a
> new Function (at which point LLVM renames it if one already exists)
> when you should really be calling GetOrInsertFunction to lookup an
> existing "printf" if it's available.
>
> Cheers.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131218/b5c84524/attachment.html>


More information about the llvm-dev mailing list