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

Richard Smith metafoo at gmail.com
Thu Jan 16 18:23:05 PST 2014


On Wed Jan 15 2014 at 8:41:28 PM, James Stark <mrjamesstark at gmail.com>
wrote:

> Hi,
>
> 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
>

You can use -fno-builtin to instruct Clang not to treat standard C library
functions as having known, built-in semantics.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140117/227cf0a1/attachment.html>


More information about the cfe-dev mailing list