hameeza ahmed via llvm-dev
2019-Jan-01 21:41 UTC
[llvm-dev] LLVM IR linking separate function definitions in header files in single IR
Hello, I have different codes with separate files with functions implemented. I want to view all function definitions/ instructions in single IR. I am able to do this by llvm-link for codes which have definition implemented in .c files... But there are some codes which have definitions instructions in header files. These functions are called from .c file. I want to have a single IR with all the definitions of the called functions that are implemented in header files.. How to do this? Please help... Thank You Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190102/c85de6cd/attachment.html>
Alberto Barbaro via llvm-dev
2019-Jan-02 17:27 UTC
[llvm-dev] LLVM IR linking separate function definitions in header files in single IR
Hi Ahmed, I don't know if I understood you problem properly but can't you just compile the projects separately in bitcode and link them using llvm-link? Can you create a GitHub repo with a similar struct so it'd be easier to help? Thanks On Tue, Jan 1, 2019, 21:41 hameeza ahmed via llvm-dev < llvm-dev at lists.llvm.org wrote:> Hello, > I have different codes with separate files with functions implemented. I > want to view all function definitions/ instructions in single IR. I am able > to do this by llvm-link for codes which have definition implemented in .c > files... > But there are some codes which have definitions instructions in header > files. These functions are called from .c file. I want to have a single IR > with all the definitions of the called functions that are implemented in > header files.. > > How to do this? > Please help... > > Thank You > Regards > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://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/20190102/7fc6ac45/attachment.html>
Mehdi AMINI via llvm-dev
2019-Jan-03 23:21 UTC
[llvm-dev] LLVM IR linking separate function definitions in header files in single IR
On Tue, Jan 1, 2019 at 1:41 PM hameeza ahmed via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello, > I have different codes with separate files with functions implemented. I > want to view all function definitions/ instructions in single IR. I am able > to do this by llvm-link for codes which have definition implemented in .c > files... > But there are some codes which have definitions instructions in header > files. These functions are called from .c file. I want to have a single IR > with all the definitions of the called functions that are implemented in > header files.. > > How to do this? > Please help... >I assume that your "function defined in a header" are marked as inline? There is no semantic concept of "header" in C/C++: moving code from a .c to a .h (or renaming a file) does not change anything to what the compiler will do with it. Depending on the language (GNU-C89, C99 vs C++, see here: https://en.wikipedia.org/wiki/Inline_function ), the semantic of inline functions is different. If you can provide an minimal example it would be easier. Best, -- Mehdi -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190103/139199e8/attachment.html>
Mehdi AMINI via llvm-dev
2019-Jan-05 23:32 UTC
[llvm-dev] LLVM IR linking separate function definitions in header files in single IR
On Sat, Jan 5, 2019 at 3:08 PM hameeza ahmed <hahmed2305 at gmail.com> wrote:> Thank You... > My issue is i m observing malloc instructions in LLVM IR.. When I compiled > certain benchmark codes i.e graphbig. They consume memory but when I see IR > there is no malloc.. >This is confusing, you first wrote that you are "observing malloc instructions in LLVM IR" but then you wrote "when I see IR there is no malloc".> By observing in detail i came to know following line which exist in header > file new_allocator.h is taking memory; > *return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));* >Your original question was "I want to have a single IR with all the definitions of the called functions that are implemented in header files". The IR you're sending contains all the code defined in the header. The line you are posting above is present multiple times, for example in the function _ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8allocateEmPKv> but in IR there is no malloc... >Do you have calls to malloc in the source code?> how can i identify such instructions in IR...by call void @_ZN?? > My IR is attached here.. >Calls to @_Znwm are allocating memory. They are not implemented in a header: https://code.woboq.org/gcc/libstdc++-v3/libsupc++/new_op.cc.html#50 (see the call to malloc there). In general, calls to malloc can likely be caught at runtime: run in a debugger and break into malloc. best, -- Mehdi> > Please help. > > On Fri, Jan 4, 2019 at 4:21 AM Mehdi AMINI <joker.eph at gmail.com> wrote: > >> >> >> On Tue, Jan 1, 2019 at 1:41 PM hameeza ahmed via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >>> Hello, >>> I have different codes with separate files with functions implemented. I >>> want to view all function definitions/ instructions in single IR. I am able >>> to do this by llvm-link for codes which have definition implemented in .c >>> files... >>> But there are some codes which have definitions instructions in header >>> files. These functions are called from .c file. I want to have a single IR >>> with all the definitions of the called functions that are implemented in >>> header files.. >>> >>> How to do this? >>> Please help... >>> >> >> I assume that your "function defined in a header" are marked as inline? >> There is no semantic concept of "header" in C/C++: moving code from a .c to >> a .h (or renaming a file) does not change anything to what the compiler >> will do with it. >> >> Depending on the language (GNU-C89, C99 vs C++, see here: >> https://en.wikipedia.org/wiki/Inline_function ), the semantic of inline >> functions is different. >> If you can provide an minimal example it would be easier. >> >> Best, >> >> -- >> Mehdi >> >>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190105/3d6b7f2f/attachment.html>
hameeza ahmed via llvm-dev
2019-Jan-06 11:35 UTC
[llvm-dev] LLVM IR linking separate function definitions in header files in single IR
Thank You.. I am observing memory allocation instructions malloc and new operator in LLVM IR. In my considered benchmark memory is allocated using new operator as follows. *return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));* How can I observe such allocations in IR? I mean which instruction in IR is equivalent to above code i.e new operator. Please help Thank You On Sun, Jan 6, 2019 at 4:32 AM Mehdi AMINI <joker.eph at gmail.com> wrote:> > > On Sat, Jan 5, 2019 at 3:08 PM hameeza ahmed <hahmed2305 at gmail.com> wrote: > >> Thank You... >> My issue is i m observing malloc instructions in LLVM IR.. When I >> compiled certain benchmark codes i.e graphbig. They consume memory but when >> I see IR there is no malloc.. >> > > This is confusing, you first wrote that you are "observing malloc > instructions in LLVM IR" but then you wrote "when I see IR there is no > malloc". > > > >> By observing in detail i came to know following line which exist in >> header file new_allocator.h is taking memory; >> *return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));* >> > > Your original question was "I want to have a single IR with all the > definitions of the called functions that are implemented in header files". > > The IR you're sending contains all the code defined in the header. The > line you are posting above is present multiple times, for example in the > function _ZN9__gnu_cxx13new_allocatorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE8allocateEmPKv > > > >> but in IR there is no malloc... >> > > Do you have calls to malloc in the source code? > > >> how can i identify such instructions in IR...by call void @_ZN?? >> My IR is attached here.. >> > > Calls to @_Znwm are allocating memory. They are not implemented in a > header: > https://code.woboq.org/gcc/libstdc++-v3/libsupc++/new_op.cc.html#50 (see > the call to malloc there). > > In general, calls to malloc can likely be caught at runtime: run in a > debugger and break into malloc. > > best, > > -- > Mehdi > > > > >> >> Please help. >> >> On Fri, Jan 4, 2019 at 4:21 AM Mehdi AMINI <joker.eph at gmail.com> wrote: >> >>> >>> >>> On Tue, Jan 1, 2019 at 1:41 PM hameeza ahmed via llvm-dev < >>> llvm-dev at lists.llvm.org> wrote: >>> >>>> Hello, >>>> I have different codes with separate files with functions implemented. >>>> I want to view all function definitions/ instructions in single IR. I am >>>> able to do this by llvm-link for codes which have definition implemented in >>>> .c files... >>>> But there are some codes which have definitions instructions in header >>>> files. These functions are called from .c file. I want to have a single IR >>>> with all the definitions of the called functions that are implemented in >>>> header files.. >>>> >>>> How to do this? >>>> Please help... >>>> >>> >>> I assume that your "function defined in a header" are marked as >>> inline? There is no semantic concept of "header" in C/C++: moving code from >>> a .c to a .h (or renaming a file) does not change anything to what the >>> compiler will do with it. >>> >>> Depending on the language (GNU-C89, C99 vs C++, see here: >>> https://en.wikipedia.org/wiki/Inline_function ), the semantic of inline >>> functions is different. >>> If you can provide an minimal example it would be easier. >>> >>> Best, >>> >>> -- >>> Mehdi >>> >>>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190106/978dc638/attachment.html>