<div dir="ltr">What Vedant said -- the profiler runtime provides buffer API for profile dumping.  Note that value profiling dumping is not yet supported for buffer API, but since you are using Front-end based instrumentation/profile-use, value profiler is not turned on by default anyway.<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 19, 2017 at 5:29 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Dec 19, 2017, at 5:16 PM, Moshtaghi, Alireza <<a href="mailto:Alireza.Moshtaghi@netapp.com" target="_blank">Alireza.Moshtaghi@netapp.com</a>> wrote:</div><br class="m_4097951825512350465Apple-interchange-newline"><div><div class="m_4097951825512350465WordSection1" style="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;background-color:rgb(255,255,255)"><div style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Thank you<u></u><u></u></div><div style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">So it does not seem to be relevant for what I’m trying to do.<u></u><u></u></div><div style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I’m doing something unconventional.<u></u><u></u></div><div style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">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)<u></u><u></u></div><div style="margin:0cm 0cm 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">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></div></span><span>You may already have worked this out, but for completeness I'll mention that this is typically done by:</span></div><span>1. Allocating a buffer big enough to contain all the data (see __llvm_profile_get_size_<wbr>for_buffer_internal),<br></span><span>2. Filling out the buffer (see __llvm_profile_write_buffer_<wbr>internal), and</span><div><span>3. Transferring the buffer to some host machine.</span></div><div><span><span class=""><br><br><blockquote type="cite">Then dump these sections in a char * array in a c file and attribute them to be in the associated section.</blockquote><div><span><br></span></div></span><div><span>I'm not sure I follow -- why is a C file needed?</span></div><div><span><br></span></div><div><span>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><span class=""><div><span><br></span></div><br><blockquote type="cite">  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> <br>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></blockquote><div><span><br></span></div></span><div><span>What error are you getting exactly? Have you confirmed that your profile is valid?</span></div><span class="HOEnZb"><font color="#888888"><div><span><br></span></div><div><span>vedant</span></div></font></span><div><div class="h5"><br><blockquote type="cite"> <br>Any suggestion?<br> <br>Thanks<br>A<br> <br>From: <<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>> on behalf of Vedant Kumar <<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>><br>Date: Tuesday, December 19, 2017 at 11:32 AM<br>To: "Moshtaghi, Alireza" <<a href="mailto:Alireza.Moshtaghi@netapp.com" target="_blank">Alireza.Moshtaghi@netapp.com</a>><br>Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br>Subject: Re: [llvm-dev] Question about : lprofValueProfNodes<br> <br>Hi,<br> <br> <br>On Dec 19, 2017, at 10:26 AM, Moshtaghi, Alireza via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br> <br>Hi<br>This array is defined in compiler-rt: InstrProfilingValue.c but I can’t find where it is used?<br> <br>It's used in allocateOneNode(). Incrementing the current vnode pointer gives a fresh node (possibly backed by the shared pool).<br> <br><br><br>And the comment on it does not say much about why we need it either.<br> <br>It's used to avoid calling malloc(), which David (CC'd) found to be a performance improvement.<br> <br>best,<br>vedant<br><br><br>Can someone explain why we need this and where it is used?<br> <br>/* A shared static pool in addition to the vnodes statically<br>* allocated by the compiler.  */<br>COMPILER_RT_VISIBILITY ValueProfNode<br>    lprofValueProfNodes[INSTR_<wbr>PROF_VNODE_POOL_SIZE] COMPILER_RT_SECTION(COMPILER_<wbr>RT_SEG INSTR_PROF_VNODES_SECT_NAME_<wbr>STR);<br> <br>Thanks<br>A<br> <br>______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br><br><br></blockquote></div></div></span><br></div></div></blockquote></div><br></div>