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

James Stark mrjamesstark at gmail.com
Sat Jan 18 11:19:07 PST 2014


Hi Richard,

it worked like a charm! :) Thanks!!! Very much appreciated.

James

On Thu, Jan 16, 2014 at 6:23 PM, Richard Smith <metafoo at gmail.com> wrote:
> 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.



More information about the cfe-dev mailing list