<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 19, 2017, at 5:16 PM, Moshtaghi, Alireza <<a href="mailto:Alireza.Moshtaghi@netapp.com" class="">Alireza.Moshtaghi@netapp.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Thank you<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">So it does not seem to be relevant for what I’m trying to do.<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I’m doing something unconventional.<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">The objective is to implement PGO and code coverage on a system that does not exit and does not have any file io, or any of  stdc libraries that libclang-profile is using. (more like a kernel)<o:p class=""></o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">So what I’m trying to do is instead of calling __llvm_profile_write_file () from the application, read the sections __llvm_prf_data, __llvm_prf_names, __llvm_prf_cnts and __llvm_prf_vnds after the critical tasks are done and transfer them to outside of the system.</div></div></div></blockquote><div><br class=""></div><span class="">You may already have worked this out, but for completeness I'll mention that this is typically done by:</span></div><span class="">1. Allocating a buffer big enough to contain all the data (see __llvm_profile_get_size_for_buffer_internal),<br class=""></span><span class="">2. Filling out the buffer (see __llvm_profile_write_buffer_internal), and</span><div class=""><span class="">3. Transferring the buffer to some host machine.</span></div><div class=""><span class=""><br class=""><br class=""><blockquote type="cite" class="">Then dump these sections in a char * array in a c file and attribute them to be in the associated section.</blockquote><div class=""><span class=""><br class=""></span></div><div class=""><span class="">I'm not sure I follow -- why is a C file needed?</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">Once you have the buffer from step 3 on the host machine, you've got a well-formed raw profile. You should be able to fwrite() it to e.g 'default.profraw' and test that it's a valid profile with llvm-profdata.</span></div><div class=""><span class=""><br class=""></span></div><br class=""><blockquote type="cite" class="">  Then compile that file with –u__llvm_profile_runtime to create an executable that calls __llvm_profile_write_file to dump my profraw data.<br class=""> <br class="">Sofar, I’m able to do the mechanics but seems like something is going wrong because because fprofile-instr-use does not find profile data for the source files.<br class=""></blockquote><div class=""><span class=""><br class=""></span></div><div class=""><span class="">What error are you getting exactly? Have you confirmed that your profile is valid?</span></div><div class=""><span class=""><br class=""></span></div><div class=""><span class="">vedant</span></div><br class=""><blockquote type="cite" class=""> <br class="">Any suggestion?<br class=""> <br class="">Thanks<br class="">A<br class=""> <br class="">From: <<a href="mailto:vsk@apple.com" class="">vsk@apple.com</a>> on behalf of Vedant Kumar <vsk@apple.com><br class="">Date: Tuesday, December 19, 2017 at 11:32 AM<br class="">To: "Moshtaghi, Alireza" <Alireza.Moshtaghi@netapp.com><br class="">Cc: llvm-dev <llvm-dev@lists.llvm.org>, Xinliang David Li <davidxl@google.com><br class="">Subject: Re: [llvm-dev] Question about : lprofValueProfNodes<br class=""> <br class="">Hi,<br class=""> <br class=""> <br class="">On Dec 19, 2017, at 10:26 AM, Moshtaghi, Alireza via llvm-dev <llvm-dev@lists.llvm.org> wrote:<br class=""> <br class="">Hi<br class="">This array is defined in compiler-rt: InstrProfilingValue.c but I can’t find where it is used?<br class=""> <br class="">It's used in allocateOneNode(). Incrementing the current vnode pointer gives a fresh node (possibly backed by the shared pool).<br class=""> <br class=""><br class=""><br class="">And the comment on it does not say much about why we need it either.<br class=""> <br class="">It's used to avoid calling malloc(), which David (CC'd) found to be a performance improvement.<br class=""> <br class="">best,<br class="">vedant<br class=""><br class=""><br class="">Can someone explain why we need this and where it is used?<br class=""> <br class="">/* A shared static pool in addition to the vnodes statically<br class="">* allocated by the compiler.  */<br class="">COMPILER_RT_VISIBILITY ValueProfNode<br class="">    lprofValueProfNodes[INSTR_PROF_VNODE_POOL_SIZE] COMPILER_RT_SECTION(COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME_STR);<br class=""> <br class="">Thanks<br class="">A<br class=""> <br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class="">llvm-dev@lists.llvm.org<br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""><br class=""><br class=""></blockquote></span><br class=""></div></body></html>