[cfe-dev] Fwd: How to differentiate standard libc calls from intrinsics

James Stark mrjamesstark at gmail.com
Tue Jan 14 04:54:27 PST 2014


My LLVM pass scans call instructions for standard C library calls. For
some libc functions, however, clang 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 clang implicitly uses llvm.memcpy intrinsics
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 intrinsic?

For example,

memcpy(buffer, "aa", 1);  // clang uses llvm.memcpy for this statement

char* buffer[] = {"xxx", "yyy"}; // clang also uses llvm.memcpy for
this statement


More information about the cfe-dev mailing list