<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jan 5, 2019 at 3:08 PM hameeza ahmed <<a href="mailto:hahmed2305@gmail.com">hahmed2305@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Thank You...</div><div>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.. </div></div></div></div></blockquote><div><br></div><div>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".</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>By observing in detail i came to know following line which exist in header file new_allocator.h is taking memory;</div><div><b>return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));</b></div></div></div></div></blockquote><div><br></div><div>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".</div><div><br></div><div>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</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>but in IR there is no malloc...</div></div></div></div></blockquote><div><br></div><div>Do you have calls to malloc in the source code?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>how can i identify such instructions in IR...by call void @_ZN??</div><div>My IR is attached here..</div></div></div></div></blockquote><div><br></div><div>Calls to @_Znwm are allocating memory. They are not implemented in a header: <a href="https://code.woboq.org/gcc/libstdc++-v3/libsupc++/new_op.cc.html#50">https://code.woboq.org/gcc/libstdc++-v3/libsupc++/new_op.cc.html#50</a> (see the call to malloc there).</div><div><br></div><div>In general, calls to malloc can likely be caught at runtime: run in a debugger and break into malloc.</div><div><br></div><div>best,</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>Please help.<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 4, 2019 at 4:21 AM Mehdi AMINI <<a href="mailto:joker.eph@gmail.com" target="_blank">joker.eph@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 1, 2019 at 1:41 PM hameeza ahmed via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div>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...</div><div>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..</div><div><br></div><div>How to do this?</div><div>Please help...</div></div></blockquote><div><br></div><div>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.</div><div><br></div><div>Depending on the language (GNU-C89, C99 vs C++, see here: <a href="https://en.wikipedia.org/wiki/Inline_function" target="_blank">https://en.wikipedia.org/wiki/Inline_function</a> ), the semantic of inline functions is different. </div><div>If you can provide an minimal example it would be easier.</div><div><br></div><div>Best,</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div></div></div></div></div>
</blockquote></div>
</blockquote></div></div></div></div></div></div></div></div>