<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">For __llvm_profile_get_size_for_buffer_internal and __llvm_profile_write_buffer_internal to work in our system, we have to modify the compiler-rt to use our kernel’s memory allocation. To avoid that, I was hoping to be able to do all the
 processing offline by copying only the sections to that offline process.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We currently have a workaround, but please let me know if you think just copying the __llvm_prf_xxx sections and doing the processing offline is not possible with the current API of compiler-rt profiling.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks<o:p></o:p></p>
<p class="MsoNormal">A<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Xinliang David Li <davidxl@google.com><br>
<b>Date: </b>Tuesday, December 19, 2017 at 5:38 PM<br>
<b>To: </b>Vedant Kumar <vsk@apple.com><br>
<b>Cc: </b>"Moshtaghi, Alireza" <Alireza.Moshtaghi@netapp.com>, llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject: </b>Re: [llvm-dev] Question about : lprofValueProfNodes<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">David<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Tue, Dec 19, 2017 at 5:29 PM, Vedant Kumar <<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="background:white">Thank you<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">So it does not seem to be relevant for what I’m trying to do.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">I’m doing something unconventional.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">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></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">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.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">You may already have worked this out, but for completeness I'll mention that this is typically done by:<o:p></o:p></p>
</div>
<p class="MsoNormal">1. Allocating a buffer big enough to contain all the data (see __llvm_profile_get_size_for_buffer_internal),<br>
2. Filling out the buffer (see __llvm_profile_write_buffer_internal), and <o:p></o:p></p>
<div>
<p class="MsoNormal">3. Transferring the buffer to some host machine.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Then dump these sections in a char * array in a c file and attribute them to be in the associated section.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm not sure I follow -- why is a C file needed?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"> 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.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">What error are you getting exactly? Have you confirmed that your profile is valid?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888">vedant<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"> <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_PROF_VNODE_POOL_SIZE] COMPILER_RT_SECTION(COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME_STR);<br>
 <br>
Thanks<br>
A<br>
 <br>
_______________________________________________<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/mailman/listinfo/llvm-dev</a><br>
<br>
<o:p></o:p></p>
</blockquote>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>