James Stark
2014-Jan-13 12:18 UTC
[LLVMdev] How to differentiate standard libc calls from intrinsics
Hi, 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 intrinsic? 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. Thanks! -JS
James Stark
2014-Jan-13 13:21 UTC
[LLVMdev] How to differentiate standard libc calls from intrinsics
correction: Actually, I won't even be able to take advantage of the following fact because all memcpy calls (either libc or intrinsics) will appear as intrinsic calls anyway. 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... On Mon, Jan 13, 2014 at 4:18 AM, James Stark <mrjamesstark at gmail.com> wrote:> Hi, > > 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 > intrinsic? > > 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. > > Thanks! > -JS
Hal Finkel
2014-Jan-16 05:18 UTC
[LLVMdev] How to differentiate standard libc calls from intrinsics
James, Can you explain in more detail what you're trying to do? -Hal ----- Original Message -----> From: "James Stark" <mrjamesstark at gmail.com> > To: llvmdev at cs.uiuc.edu > Sent: Monday, January 13, 2014 6:18:01 AM > Subject: [LLVMdev] How to differentiate standard libc calls from intrinsics > > Hi, > > 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 > intrinsic? > > 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. > > Thanks! > -JS > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Hal Finkel Assistant Computational Scientist Leadership Computing Facility Argonne National Laboratory
James Stark
2014-Jan-18 19:18 UTC
[LLVMdev] How to differentiate standard libc calls from intrinsics
Hi Hal, I'm trying to find how many libc calls exist in a bitcode file. Since some libc calls appear as LLVM intrinsics, I can't find those. I've found from other source that -fno-builtin works like a charm. Hope this will help other people looking for a solution. Thanks, James. On Wed, Jan 15, 2014 at 9:18 PM, Hal Finkel <hfinkel at anl.gov> wrote:> James, > > Can you explain in more detail what you're trying to do? > > -Hal > > ----- Original Message ----- >> From: "James Stark" <mrjamesstark at gmail.com> >> To: llvmdev at cs.uiuc.edu >> Sent: Monday, January 13, 2014 6:18:01 AM >> Subject: [LLVMdev] How to differentiate standard libc calls from intrinsics >> >> Hi, >> >> 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 >> intrinsic? >> >> 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. >> >> Thanks! >> -JS >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > -- > Hal Finkel > Assistant Computational Scientist > Leadership Computing Facility > Argonne National Laboratory
Apparently Analagous Threads
- [LLVMdev] How to read v3.3 dbg metadata using v3.4 LLVM
- Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?
- Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?
- Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?
- [LLVMdev] Clang question