[llvm-dev] How to distinguish between user defined function in a program and library functions (original) (raw)
George Burgess IV via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 7 16:04:28 PST 2020
- Previous message: [llvm-dev] How to distinguish between user defined function in a program and library functions
- Next message: [llvm-dev] InstCombiner bug
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'd imagine you can tweak clang's CodeGen to add a Metadata node to all
llvm::Function
s clang emits that basically says whether or not the code
appeared in a system header. SourceManager::isInSystemHeader should help
you figure out what's where. You'll probably need special handling for
generated code, like __cxx_global_var_init
I offer no guarantees about the LLVM community accepting this patch, though :)
To Mehdi's point, inlining can make things materially more difficult.
On Wed, Feb 5, 2020 at 10:16 AM Jacob Carlborg via llvm-dev < llvm-dev at lists.llvm.org> wrote:
On 2020-02-04 17:24, Sunil via llvm-dev 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'.
Perhaps you can check where a function is defined and treat all functions defined in a file passed to the compiler as user defined and all other as system defined. Not sure if that's good enough for you. -- /Jacob Carlborg
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/20200207/5d1b9975/attachment.html>
- Previous message: [llvm-dev] How to distinguish between user defined function in a program and library functions
- Next message: [llvm-dev] InstCombiner bug
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]