[LLVMdev] How to differentiate standard libc calls from intrinsics

James Stark mrjamesstark at gmail.com
Mon Jan 13 04:18:01 PST 2014


My pass scans call instructions for standard C library calls. For some
libc functions, however, LLVM uses intrinsics instead. For example, I
see that my memcpy calls are replaced by the llvm.memcpy.* intrinsics.
This is not a problem because I can simply look for llvm.memcpy calls
when scanning for memcpy calls.

The problem arises when LLVM implicitly inserts llvm.memcpy intrinsics
into my bitcode files when it thinks they are needed. In this case, I
do not see a single memcpy call in my source file but its IR does have
them. How do I make a distinction between a real C library call and an

Btw, for this memcpy case, I should be able to take advantage of this fact:

http://llvm.org/docs/LangRef.html#llvm-memcpy-intrinsic: "Note that,
unlike the standard libc function, the llvm.memcpy.* intrinsics do not
return a value..."

However, I'm looking for a general solution for all libc intrinsics
listed at http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics.


More information about the llvm-dev mailing list