[llvm-dev] How to distinguish between user defined function in a program and library functions (original) (raw)

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 4 20:10:12 PST 2020


LLVM's analysis infrastructure is mostly intended for optimizations, which should apply to any code equally - I don't believe there's any bit that tracks which functions came from system libraries or not.

On Tue, Feb 4, 2020 at 8:01 PM sunilps <sunilps at iitk.ac.in> wrote:

Actually I want to run some analysis pass only on the user defined functions but not on the library functions. Is there any boolean method that can tell which is a library function and which is not? On 5 Feb 2020 5:23 a.m., David Blaikie <dblaikie at gmail.com> wrote: Generally, you can't - and optimizations/the compiler shouldn't differentiate between them. On Tue, Feb 4, 2020 at 3:25 PM Sunil via llvm-dev <llvm-dev at lists.llvm.org> wrote:

Say, I have the following program: #include int main(){ std::cout << "hello\n"; return 0; }

After generating llvm bitcode using the following command: $ clang++ -c -emit-llvm -O -Xclang -disable-llvm-passes a.cpp the bitcode has the following function with define. _cxxglobalvarinit main ZStlsISt11chartraitsIcEERSt13basicostreamIcTES5PKc ZNSt9basiciosIcSt11chartraitsIcEE8setstateESt12IosIostate ZNSt11chartraitsIcE6lengthEPKc ZStorSt12IosIostateS ZNKSt9basiciosIcSt11chartraitsIcEE7rdstateEv GLOBAL_subIa.cpp In a pass, I want to know what are the functions defined by the user e.g 'main' and what are not e.g. other than 'main'. Regards, Sunil


LLVM Developers mailing list llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200204/94bc8576/attachment.html>



More information about the llvm-dev mailing list